瀏覽代碼

Merge pull request #8722 from kylestarr/master

Update scripting_player_input.rst

(cherry picked from commit a621959d860f6dcc4208d2ac48334a4e089b561e)
Matthew 1 年之前
父節點
當前提交
75e7d6caf0
共有 1 個文件被更改,包括 19 次插入1 次删除
  1. 19 1
      getting_started/step_by_step/scripting_player_input.rst

+ 19 - 1
getting_started/step_by_step/scripting_player_input.rst

@@ -79,6 +79,24 @@ right arrows on the keyboard or left and right on a gamepad's D-pad.
 Finally, we use the ``direction`` as a multiplier when we update the node's
 ``rotation``: ``rotation += angular_speed * direction * delta``.
 
+Comment out the lines ``var velocity = Vector2.UP.rotated(rotation) * speed`` and ``position += velocity * delta`` like this:
+
+.. tabs::
+
+ .. code-tab:: gdscript GDScript
+
+    #var velocity = Vector2.UP.rotated(rotation) * speed
+	
+    #position += velocity * delta
+
+ .. code-tab:: csharp C#
+
+    //var velocity = Vector2.Up.Rotated(Rotation) * _speed;
+
+    //Position += velocity * (float)delta;
+
+This will ignore the code that moved the icon's position in a circle without user input from the previous exercise.
+
 If you run the scene with this code, the icon should rotate when you press
 :kbd:`Left` and :kbd:`Right`.
 
@@ -86,7 +104,7 @@ Moving when pressing "up"
 -------------------------
 
 To only move when pressing a key, we need to modify the code that calculates the
-velocity. Replace the line starting with ``var velocity`` with the code below.
+velocity. Uncomment the code and replace the line starting with ``var velocity`` with the code below.
 
 .. tabs::
  .. code-tab:: gdscript GDScript