Merge pull request #2326 from cbscribe/2d_movement_fix

Fix `move_and_slide()` usage in 2D movement tutorial
This commit is contained in:
Chris Bradfield
2019-04-08 14:23:26 -07:00
committed by GitHub
+8 -8
View File
@@ -59,7 +59,7 @@ Add a script to the kinematic body and add the following code:
func _physics_process(delta):
get_input()
move_and_slide(velocity)
velocity = move_and_slide(velocity)
.. code-tab:: csharp
@@ -94,7 +94,7 @@ Add a script to the kinematic body and add the following code:
public override void _PhysicsProcess(float delta)
{
GetInput();
MoveAndSlide(velocity);
velocity = MoveAndSlide(velocity);
}
}
@@ -144,7 +144,7 @@ while up/down moves it forward or backward in whatever direction it's facing.
func _physics_process(delta):
get_input()
rotation += rotation_dir * rotation_speed * delta
move_and_slide(velocity)
velocity = move_and_slide(velocity)
.. code-tab:: csharp
@@ -183,7 +183,7 @@ while up/down moves it forward or backward in whatever direction it's facing.
{
GetInput();
Rotation += rotationDir * RotationSpeed * delta;
MoveAndSlide(velocity);
velocity = MoveAndSlide(velocity);
}
}
@@ -224,7 +224,7 @@ is set by the mouse position instead of the keyboard. The character will always
func _physics_process(delta):
get_input()
move_and_slide(velocity)
velocity = move_and_slide(velocity)
.. code-tab:: csharp
@@ -254,7 +254,7 @@ is set by the mouse position instead of the keyboard. The character will always
public override void _PhysicsProcess(float delta)
{
GetInput();
MoveAndSlide(velocity);
velocity = MoveAndSlide(velocity);
}
}
@@ -298,7 +298,7 @@ on the screen will cause the player to move to the target location.
velocity = (target - position).normalized() * speed
# rotation = velocity.angle()
if (target - position).length() > 5:
move_and_slide(velocity)
velocity = move_and_slide(velocity)
.. code-tab:: csharp
@@ -326,7 +326,7 @@ on the screen will cause the player to move to the target location.
// Rotation = velocity.Angle();
if ((target - Position).Length() > 5)
{
MoveAndSlide(velocity);
velocity = MoveAndSlide(velocity);
}
}
}