Skip to content

Commit fd14417

Browse files
authored
Merge pull request #10807 from Piralein/update-3d-player-img
Update images and clarify instructions in "Getting Started 3D - Player Input"
2 parents e44bbb6 + 8f2068e commit fd14417

35 files changed

+39
-58
lines changed

getting_started/first_3d_game/02.player_input.rst

Lines changed: 39 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -7,19 +7,17 @@ In the next two lessons, we will design the player scene, register custom input
77
actions, and code player movement. By the end, you'll have a playable character
88
that moves in eight directions.
99

10-
.. TODO: add player animated gif?
11-
.. player_movement.gif
10+
Create a new scene by going to the **Scene** menu in the top-left
11+
and clicking **New Scene**.
1212

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

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

2018
.. image:: img/02.player_input/add_character_body3D.webp
2119

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

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

3939
.. image:: img/02.player_input/adding_node3D.webp
4040

4141
Then, in the FileSystem dock, expand the ``art/`` folder
4242
by double-clicking it and drag and
4343
drop ``player.glb`` onto ``Pivot``.
4444

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

4747
This should instantiate the model as a child of ``Pivot``.
4848
You can rename it to ``Character``.
4949

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

5252
.. note::
5353

@@ -58,28 +58,29 @@ You can rename it to ``Character``.
5858

5959
As with all kinds of physics nodes, we need a collision shape for our character
6060
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>`.
61+
:ref:`CollisionShape3D <class_CollisionShape3D>`. In the **Inspector**, on the **Shape** property,
62+
add a new :ref:`SphereShape3D <class_SphereShape3D>`.
6263

6364
.. image:: img/02.player_input/add_capsuleshape3d.webp
6465

6566
The sphere's wireframe appears below the character.
6667

67-
|image3|
68+
.. image:: img/02.player_input/sphere_shape.png
6869

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

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

75-
|image4|
76+
.. image:: img/02.player_input/moving_the_sphere_up.png
7677

7778
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.
79+
the **eye icon** next to the ``Character`` or the ``Pivot`` nodes.
7980

80-
|image5|
81+
.. image:: img/02.player_input/toggling_visibility.webp
8182

82-
Save the scene as ``player.tscn``
83+
Save the scene as ``player.tscn``.
8384

8485
With the nodes ready, we can almost get coding. But first, we need to define
8586
some input actions.
@@ -94,52 +95,49 @@ arrow keys. In Godot, while we could write all the key bindings in code, there's
9495
a powerful system that allows you to assign a label to a set of keys and
9596
buttons. This simplifies our scripts and makes them more readable.
9697

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

100-
|image6|
101+
.. image:: img/02.player_input/project_settings.webp
101102

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

106-
|image7|
107+
.. image:: img/02.player_input/input_map_tab.webp
107108

108109
Godot projects come with some predefined actions designed for user interface
109110
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.
111+
**Show Built-in Actions** toggle. We could use these here, but instead we're
112+
defining our own to support gamepads. Leave **Show Built-in Actions** disabled.
112113

113114
We're going to name our actions ``move_left``, ``move_right``, ``move_forward``,
114115
``move_back``, and ``jump``.
115116

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

118-
|image8|
119+
.. image:: img/02.player_input/adding_action.webp
119120

120121
Create the following five actions:
121122

122-
|image9|
123+
.. image:: img/02.player_input/actions_list_empty.webp
123124

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*.
125+
To bind a key or button to an action, click the "**+**" button to its right. Do this
126+
for ``move_left``. Press the left arrow key and click **OK**.
126127

127128
.. image:: img/02.player_input/left_inputmap.webp
128129

129130
Bind also the :kbd:`A` key, onto the action ``move_left``.
130131

131-
|image12|
132+
.. image:: img/02.player_input/keyboard_keys.webp
132133

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*.
134+
Let's now add support for a gamepad's left joystick. Click the "**+**" button again
135+
but this time, select the input within the input tree yourself.
136+
Select the negative X axis of the left joystick under **Joypad Axes**.
135137

136138
.. image:: img/02.player_input/joystick_axis_input.webp
137139

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*
140+
Leave the other values as default and press **OK**.
143141

144142
.. note::
145143

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

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

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

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

159157
Your jump input action should look like this.
160158

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

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

166164
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)