Skip to content

Commit a621959

Browse files
authored
Merge pull request godotengine#8722 from kylestarr/master
Update scripting_player_input.rst
2 parents 47ee233 + 16a90c8 commit a621959

File tree

1 file changed

+19
-1
lines changed

1 file changed

+19
-1
lines changed

getting_started/step_by_step/scripting_player_input.rst

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,14 +79,32 @@ right arrows on the keyboard or left and right on a gamepad's D-pad.
7979
Finally, we use the ``direction`` as a multiplier when we update the node's
8080
``rotation``: ``rotation += angular_speed * direction * delta``.
8181

82+
Comment out the lines ``var velocity = Vector2.UP.rotated(rotation) * speed`` and ``position += velocity * delta`` like this:
83+
84+
.. tabs::
85+
86+
.. code-tab:: gdscript GDScript
87+
88+
#var velocity = Vector2.UP.rotated(rotation) * speed
89+
90+
#position += velocity * delta
91+
92+
.. code-tab:: csharp C#
93+
94+
//var velocity = Vector2.Up.Rotated(Rotation) * _speed;
95+
96+
//Position += velocity * (float)delta;
97+
98+
This will ignore the code that moved the icon's position in a circle without user input from the previous exercise.
99+
82100
If you run the scene with this code, the icon should rotate when you press
83101
:kbd:`Left` and :kbd:`Right`.
84102

85103
Moving when pressing "up"
86104
-------------------------
87105

88106
To only move when pressing a key, we need to modify the code that calculates the
89-
velocity. Replace the line starting with ``var velocity`` with the code below.
107+
velocity. Uncomment the code and replace the line starting with ``var velocity`` with the code below.
90108

91109
.. tabs::
92110
.. code-tab:: gdscript GDScript

0 commit comments

Comments
 (0)