Browse Source

Merge pull request #3521 from mukul29/master

Removed redundant code recalculating velocity
Chris Bradfield 5 years ago
parent
commit
9cd7cbf8e0
1 changed files with 2 additions and 8 deletions
  1. 2 8
      getting_started/step_by_step/exporting.rst

+ 2 - 8
getting_started/step_by_step/exporting.rst

@@ -84,9 +84,7 @@ changed:
         var velocity = Vector2()
         var velocity = Vector2()
         # Move towards the target and stop when close.
         # Move towards the target and stop when close.
         if position.distance_to(target) > 10:
         if position.distance_to(target) > 10:
-            velocity = (target - position).normalized() * speed
-        else:
-            velocity = Vector2()
+            velocity = target - position
 
 
     # Remove keyboard controls.
     # Remove keyboard controls.
     #    if Input.is_action_pressed("ui_right"):
     #    if Input.is_action_pressed("ui_right"):
@@ -172,11 +170,7 @@ changed:
             // Move towards the target and stop when close.
             // Move towards the target and stop when close.
             if (Position.DistanceTo(_target) > 10)
             if (Position.DistanceTo(_target) > 10)
             {
             {
-                velocity = (_target - Position).Normalized() * Speed;
-            }
-            else
-            {
-                velocity = new Vector2();
+                velocity = _target - Position
             }
             }
 
 
             // Remove keyboard controls.
             // Remove keyboard controls.