Skip to content

Commit f5c598e

Browse files
committed
update images and clarify instructions
1 parent 2ec67eb commit f5c598e

35 files changed

+38
-55
lines changed

getting_started/first_3d_game/02.player_input.rst

Lines changed: 38 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -9,17 +9,17 @@ that moves in eight directions.
99

1010
.. TODO: add player animated gif?
1111
.. player_movement.gif
12+
Create a new scene by going to the **Scene** menu in the top-left
13+
and clicking **New Scene**.
1214

13-
Create a new scene by going to the Scene menu in the top-left and clicking *New
14-
Scene*.
15+
.. image:: img/02.player_input/new_scene.webp
1516

16-
|image0|
17-
18-
Create a :ref:`CharacterBody3D <class_CharacterBody3D>` node as the root
17+
Click the **Other Node** button and select the ``CharacterBody3D`` node type
18+
to create a :ref:`CharacterBody3D <class_CharacterBody3D>` as the root node.
1919

2020
.. image:: img/02.player_input/add_character_body3D.webp
2121

22-
Name the :ref:`CharacterBody3D <class_CharacterBody3D>` to ``Player``.
22+
Rename the :ref:`CharacterBody3D <class_CharacterBody3D>` to ``Player``.
2323
Character bodies are complementary to the area and rigid bodies used in the 2D
2424
game tutorial. Like rigid bodies, they can move and collide with the
2525
environment, but instead of being controlled by the physics engine, **you** dictate
@@ -34,20 +34,22 @@ the jump and squash mechanics.
3434
For now, we're going to create a basic rig for our character's 3D model. This
3535
will allow us to rotate the model later via code while it plays an animation.
3636

37-
Add a :ref:`Node3D <class_Node3D>` node as a child of ``Player`` and name it ``Pivot``
37+
Add a :ref:`Node3D <class_Node3D>` node as a child of ``Player``.
38+
Select the ``Player`` node in the **Scene** tree and click the "**+**" button to add a child node.
39+
Rename it to ``Pivot``.
3840

3941
.. image:: img/02.player_input/adding_node3D.webp
4042

4143
Then, in the FileSystem dock, expand the ``art/`` folder
4244
by double-clicking it and drag and
4345
drop ``player.glb`` onto ``Pivot``.
4446

45-
|image1|
47+
.. image:: img/02.player_input/instantiating_the_model.webp
4648

4749
This should instantiate the model as a child of ``Pivot``.
4850
You can rename it to ``Character``.
4951

50-
|image2|
52+
.. image:: img/02.player_input/scene_structure.webp
5153

5254
.. note::
5355

@@ -58,26 +60,27 @@ You can rename it to ``Character``.
5860

5961
As with all kinds of physics nodes, we need a collision shape for our character
6062
to collide with the environment. Select the ``Player`` node again and add a child node
61-
:ref:`CollisionShape3D <class_CollisionShape3D>`. In the *Inspector*, on the *Shape* property, add a new :ref:`SphereShape3D <class_SphereShape3D>`.
63+
:ref:`CollisionShape3D <class_CollisionShape3D>`. In the **Inspector**, on the **Shape** property,
64+
add a new :ref:`SphereShape3D <class_SphereShape3D>`.
6265

6366
.. image:: img/02.player_input/add_capsuleshape3d.webp
6467

6568
The sphere's wireframe appears below the character.
6669

67-
|image3|
70+
.. image:: img/02.player_input/sphere_shape.png
6871

6972
It will be the shape the physics engine uses to collide with the environment, so
7073
we want it to better fit the 3D model. Make it a bit larger by dragging the orange
7174
dot in the viewport. My sphere has a radius of about ``0.8`` meters.
7275

7376
Then, move the collision shape up so its bottom roughly aligns with the grid's plane.
7477

75-
|image4|
78+
.. image:: img/02.player_input/moving_the_sphere_up.png
7679

7780
To make moving the shape easier, you can toggle the model's visibility by clicking
78-
the eye icon next to the ``Character`` or the ``Pivot`` nodes.
81+
the **eye icon** next to the ``Character`` or the ``Pivot`` nodes.
7982

80-
|image5|
83+
.. image:: img/02.player_input/toggling_visibility.webp
8184

8285
Save the scene as ``player.tscn``
8386

@@ -94,52 +97,49 @@ arrow keys. In Godot, while we could write all the key bindings in code, there's
9497
a powerful system that allows you to assign a label to a set of keys and
9598
buttons. This simplifies our scripts and makes them more readable.
9699

97-
This system is the Input Map. To access its editor, head to the *Project* menu
98-
and select *Project Settings*.
100+
This system is the Input Map. To access its editor, head to the **Project** menu
101+
and select **Project Settings...**.
99102

100-
|image6|
103+
.. image:: img/02.player_input/project_settings.webp
101104

102-
At the top, there are multiple tabs. Click on *Input Map*. This window allows
105+
At the top, there are multiple tabs. Click on **Input Map**. This window allows
103106
you to add new actions at the top; they are your labels. In the bottom part, you
104107
can bind keys to these actions.
105108

106-
|image7|
109+
.. image:: img/02.player_input/input_map_tab.webp
107110

108111
Godot projects come with some predefined actions designed for user interface
109112
design (see above screenshot). These will become visible if you enable the
110-
*Show Built-in Actions* toggle. We could use these here, but instead we're
111-
defining our own to support gamepads. Leave *Show Built-in Actions* disabled.
113+
**Show Built-in Actions** toggle. We could use these here, but instead we're
114+
defining our own to support gamepads. Leave **Show Built-in Actions** disabled.
112115

113116
We're going to name our actions ``move_left``, ``move_right``, ``move_forward``,
114117
``move_back``, and ``jump``.
115118

116-
To add an action, write its name in the bar at the top and press Enter.
119+
To add an action, write its name in the bar at the top and press Enter or click the **Add** button.
117120

118-
|image8|
121+
.. image:: img/02.player_input/adding_action.webp
119122

120123
Create the following five actions:
121124

122-
|image9|
125+
.. image:: img/02.player_input/actions_list_empty.webp
123126

124-
To bind a key or button to an action, click the "+" button to its right. Do this
125-
for ``move_left``. Press the left arrow key and click *OK*.
127+
To bind a key or button to an action, click the "**+**" button to its right. Do this
128+
for ``move_left``. Press the left arrow key and click **OK**.
126129

127130
.. image:: img/02.player_input/left_inputmap.webp
128131

129132
Bind also the :kbd:`A` key, onto the action ``move_left``.
130133

131-
|image12|
134+
.. image:: img/02.player_input/keyboard_keys.webp
132135

133-
Let's now add support for a gamepad's left joystick. Click the "+" button again
134-
but this time, select *Manual Selection -> Joypad Axes*.
136+
Let's now add support for a gamepad's left joystick. Click the "**+**" button again
137+
but this time, select the input within the input tree yourself.
138+
Select the negative X axis of the left joystick under **Joypad Axes**.
135139

136140
.. image:: img/02.player_input/joystick_axis_input.webp
137141

138-
Select the negative X axis of the left joystick.
139-
140-
.. image:: img/02.player_input/left_joystick_select.webp
141-
142-
Leave the other values as default and press *OK*
142+
Leave the other values as default and press **OK**.
143143

144144
.. note::
145145

@@ -149,35 +149,18 @@ Do the same for the other input actions. For example, bind the right arrow, D,
149149
and the left joystick's positive axis to ``move_right``. After binding all keys,
150150
your interface should look like this.
151151

152-
|image15|
152+
.. image:: img/02.player_input/move_inputs_mapped.webp
153153

154154
The final action to set up is the ``jump`` action. Bind the Space key and the gamepad's
155-
A button.
155+
A button located under **Joypad Buttons**.
156156

157-
|image16|
157+
.. image:: img/02.player_input/joy_button_option.webp
158158

159159
Your jump input action should look like this.
160160

161-
|image18|
161+
.. image:: img/02.player_input/jump_input_action.webp
162162

163163
That's all the actions we need for this game. You can use this menu to label any
164164
groups of keys and buttons in your projects.
165165

166166
In the next part, we'll code and test the player's movement.
167-
168-
.. |image0| image:: img/02.player_input/01.new_scene.png
169-
.. |image1| image:: img/02.player_input/02.instantiating_the_model.webp
170-
.. |image2| image:: img/02.player_input/03.scene_structure.png
171-
.. |image3| image:: img/02.player_input/04.sphere_shape.png
172-
.. |image4| image:: img/02.player_input/05.moving_the_sphere_up.png
173-
.. |image5| image:: img/02.player_input/06.toggling_visibility.webp
174-
.. |image6| image:: img/02.player_input/07.project_settings.png
175-
.. |image7| image:: img/02.player_input/07.input_map_tab.png
176-
.. |image8| image:: img/02.player_input/07.adding_action.webp
177-
.. |image9| image:: img/02.player_input/08.actions_list_empty.png
178-
.. |image11| image:: img/02.player_input/09.keyboard_key_popup.png
179-
.. |image12| image:: img/02.player_input/09.keyboard_keys.png
180-
.. |image15| image:: img/02.player_input/12.move_inputs_mapped.webp
181-
.. |image16| image:: img/02.player_input/13.joy_button_option.webp
182-
.. |image17| image:: img/02.player_input/14.add_jump_button.png
183-
.. |image18| image:: img/02.player_input/14.jump_input_action.webp
-3.74 KB
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.

0 commit comments

Comments
 (0)