mirror of
https://github.com/godotengine/godot-docs.git
synced 2026-01-04 14:11:02 +03:00
Update physics_introduction.rst (#7360)
Co-authored-by: Raul Santos <raulsntos@gmail.com>
This commit is contained in:
@@ -286,19 +286,19 @@ For example, here is the code for an "Asteroids" style spaceship:
|
||||
private Vector2 _thrust = new Vector2(0, -250);
|
||||
private float _torque = 20000;
|
||||
|
||||
public override void _IntegrateForces(Physics2DDirectBodyState state)
|
||||
public override void _IntegrateForces(PhysicsDirectBodyState2D state)
|
||||
{
|
||||
if (Input.IsActionPressed("ui_up"))
|
||||
AppliedForce = _thrust.Rotated(Rotation);
|
||||
state.ApplyForce(_thrust.Rotated(Rotation));
|
||||
else
|
||||
AppliedForce = new Vector2();
|
||||
state.ApplyForce(new Vector2());
|
||||
|
||||
var rotationDir = 0;
|
||||
if (Input.IsActionPressed("ui_right"))
|
||||
rotationDir += 1;
|
||||
if (Input.IsActionPressed("ui_left"))
|
||||
rotationDir -= 1;
|
||||
AppliedTorque = rotationDir * _torque;
|
||||
state.ApplyTorque(rotationDir * _torque);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user