diff --git a/getting_started/first_3d_game/02.player_input.rst b/getting_started/first_3d_game/02.player_input.rst index 558f94d7068..011a3786413 100644 --- a/getting_started/first_3d_game/02.player_input.rst +++ b/getting_started/first_3d_game/02.player_input.rst @@ -7,19 +7,17 @@ In the next two lessons, we will design the player scene, register custom input actions, and code player movement. By the end, you'll have a playable character that moves in eight directions. -.. TODO: add player animated gif? -.. player_movement.gif +Create a new scene by going to the **Scene** menu in the top-left +and clicking **New Scene**. -Create a new scene by going to the Scene menu in the top-left and clicking *New -Scene*. +.. image:: img/02.player_input/new_scene.webp -|image0| - - Create a :ref:`CharacterBody3D ` node as the root +Click the **Other Node** button and select the ``CharacterBody3D`` node type +to create a :ref:`CharacterBody3D ` as the root node. .. image:: img/02.player_input/add_character_body3D.webp -Name the :ref:`CharacterBody3D ` to ``Player``. +Rename the :ref:`CharacterBody3D ` to ``Player``. Character bodies are complementary to the area and rigid bodies used in the 2D game tutorial. Like rigid bodies, they can move and collide with the environment, but instead of being controlled by the physics engine, **you** dictate @@ -34,7 +32,9 @@ the jump and squash mechanics. For now, we're going to create a basic rig for our character's 3D model. This will allow us to rotate the model later via code while it plays an animation. -Add a :ref:`Node3D ` node as a child of ``Player`` and name it ``Pivot`` +Add a :ref:`Node3D ` node as a child of ``Player``. +Select the ``Player`` node in the **Scene** tree and click the "**+**" button to add a child node. +Rename it to ``Pivot``. .. image:: img/02.player_input/adding_node3D.webp @@ -42,12 +42,12 @@ Then, in the FileSystem dock, expand the ``art/`` folder by double-clicking it and drag and drop ``player.glb`` onto ``Pivot``. -|image1| +.. image:: img/02.player_input/instantiating_the_model.webp This should instantiate the model as a child of ``Pivot``. You can rename it to ``Character``. -|image2| +.. image:: img/02.player_input/scene_structure.webp .. note:: @@ -58,13 +58,14 @@ You can rename it to ``Character``. As with all kinds of physics nodes, we need a collision shape for our character to collide with the environment. Select the ``Player`` node again and add a child node -:ref:`CollisionShape3D `. In the *Inspector*, on the *Shape* property, add a new :ref:`SphereShape3D `. +:ref:`CollisionShape3D `. In the **Inspector**, on the **Shape** property, +add a new :ref:`SphereShape3D `. .. image:: img/02.player_input/add_capsuleshape3d.webp The sphere's wireframe appears below the character. -|image3| +.. image:: img/02.player_input/sphere_shape.png It will be the shape the physics engine uses to collide with the environment, so we want it to better fit the 3D model. Make it a bit larger by dragging the orange @@ -72,14 +73,14 @@ dot in the viewport. My sphere has a radius of about ``0.8`` meters. Then, move the collision shape up so its bottom roughly aligns with the grid's plane. -|image4| +.. image:: img/02.player_input/moving_the_sphere_up.png To make moving the shape easier, you can toggle the model's visibility by clicking -the eye icon next to the ``Character`` or the ``Pivot`` nodes. +the **eye icon** next to the ``Character`` or the ``Pivot`` nodes. -|image5| +.. image:: img/02.player_input/toggling_visibility.webp -Save the scene as ``player.tscn`` +Save the scene as ``player.tscn``. With the nodes ready, we can almost get coding. But first, we need to define some input actions. @@ -94,52 +95,49 @@ arrow keys. In Godot, while we could write all the key bindings in code, there's a powerful system that allows you to assign a label to a set of keys and buttons. This simplifies our scripts and makes them more readable. -This system is the Input Map. To access its editor, head to the *Project* menu -and select *Project Settings*. +This system is the Input Map. To access its editor, head to the **Project** menu +and select **Project Settings...**. -|image6| +.. image:: img/02.player_input/project_settings.webp -At the top, there are multiple tabs. Click on *Input Map*. This window allows +At the top, there are multiple tabs. Click on **Input Map**. This window allows you to add new actions at the top; they are your labels. In the bottom part, you can bind keys to these actions. -|image7| +.. image:: img/02.player_input/input_map_tab.webp Godot projects come with some predefined actions designed for user interface design (see above screenshot). These will become visible if you enable the -*Show Built-in Actions* toggle. We could use these here, but instead we're -defining our own to support gamepads. Leave *Show Built-in Actions* disabled. +**Show Built-in Actions** toggle. We could use these here, but instead we're +defining our own to support gamepads. Leave **Show Built-in Actions** disabled. We're going to name our actions ``move_left``, ``move_right``, ``move_forward``, ``move_back``, and ``jump``. -To add an action, write its name in the bar at the top and press Enter. +To add an action, write its name in the bar at the top and press Enter or click the **Add** button. -|image8| +.. image:: img/02.player_input/adding_action.webp Create the following five actions: -|image9| +.. image:: img/02.player_input/actions_list_empty.webp -To bind a key or button to an action, click the "+" button to its right. Do this -for ``move_left``. Press the left arrow key and click *OK*. +To bind a key or button to an action, click the "**+**" button to its right. Do this +for ``move_left``. Press the left arrow key and click **OK**. .. image:: img/02.player_input/left_inputmap.webp Bind also the :kbd:`A` key, onto the action ``move_left``. -|image12| +.. image:: img/02.player_input/keyboard_keys.webp -Let's now add support for a gamepad's left joystick. Click the "+" button again -but this time, select *Manual Selection -> Joypad Axes*. +Let's now add support for a gamepad's left joystick. Click the "**+**" button again +but this time, select the input within the input tree yourself. +Select the negative X axis of the left joystick under **Joypad Axes**. .. image:: img/02.player_input/joystick_axis_input.webp -Select the negative X axis of the left joystick. - -.. image:: img/02.player_input/left_joystick_select.webp - -Leave the other values as default and press *OK* +Leave the other values as default and press **OK**. .. note:: @@ -149,35 +147,18 @@ Do the same for the other input actions. For example, bind the right arrow, D, and the left joystick's positive axis to ``move_right``. After binding all keys, your interface should look like this. -|image15| +.. image:: img/02.player_input/move_inputs_mapped.webp The final action to set up is the ``jump`` action. Bind the Space key and the gamepad's -A button. +A button located under **Joypad Buttons**. -|image16| +.. image:: img/02.player_input/joy_button_option.webp Your jump input action should look like this. -|image18| +.. image:: img/02.player_input/jump_input_action.webp That's all the actions we need for this game. You can use this menu to label any groups of keys and buttons in your projects. In the next part, we'll code and test the player's movement. - -.. |image0| image:: img/02.player_input/01.new_scene.png -.. |image1| image:: img/02.player_input/02.instantiating_the_model.webp -.. |image2| image:: img/02.player_input/03.scene_structure.png -.. |image3| image:: img/02.player_input/04.sphere_shape.png -.. |image4| image:: img/02.player_input/05.moving_the_sphere_up.png -.. |image5| image:: img/02.player_input/06.toggling_visibility.webp -.. |image6| image:: img/02.player_input/07.project_settings.png -.. |image7| image:: img/02.player_input/07.input_map_tab.png -.. |image8| image:: img/02.player_input/07.adding_action.webp -.. |image9| image:: img/02.player_input/08.actions_list_empty.png -.. |image11| image:: img/02.player_input/09.keyboard_key_popup.png -.. |image12| image:: img/02.player_input/09.keyboard_keys.png -.. |image15| image:: img/02.player_input/12.move_inputs_mapped.webp -.. |image16| image:: img/02.player_input/13.joy_button_option.webp -.. |image17| image:: img/02.player_input/14.add_jump_button.png -.. |image18| image:: img/02.player_input/14.jump_input_action.webp diff --git a/getting_started/first_3d_game/img/02.player_input/01.new_scene.png b/getting_started/first_3d_game/img/02.player_input/01.new_scene.png deleted file mode 100644 index 5333083df06..00000000000 Binary files a/getting_started/first_3d_game/img/02.player_input/01.new_scene.png and /dev/null differ diff --git a/getting_started/first_3d_game/img/02.player_input/02.instantiating_the_model.webp b/getting_started/first_3d_game/img/02.player_input/02.instantiating_the_model.webp deleted file mode 100644 index ef52664e1e4..00000000000 Binary files a/getting_started/first_3d_game/img/02.player_input/02.instantiating_the_model.webp and /dev/null differ diff --git a/getting_started/first_3d_game/img/02.player_input/03.scene_structure.png b/getting_started/first_3d_game/img/02.player_input/03.scene_structure.png deleted file mode 100644 index 6ba15494087..00000000000 Binary files a/getting_started/first_3d_game/img/02.player_input/03.scene_structure.png and /dev/null differ diff --git a/getting_started/first_3d_game/img/02.player_input/06.toggling_visibility.webp b/getting_started/first_3d_game/img/02.player_input/06.toggling_visibility.webp deleted file mode 100644 index fe0b71cb892..00000000000 Binary files a/getting_started/first_3d_game/img/02.player_input/06.toggling_visibility.webp and /dev/null differ diff --git a/getting_started/first_3d_game/img/02.player_input/07.adding_action.webp b/getting_started/first_3d_game/img/02.player_input/07.adding_action.webp deleted file mode 100644 index b6aaabba33e..00000000000 Binary files a/getting_started/first_3d_game/img/02.player_input/07.adding_action.webp and /dev/null differ diff --git a/getting_started/first_3d_game/img/02.player_input/07.input_map_tab.png b/getting_started/first_3d_game/img/02.player_input/07.input_map_tab.png deleted file mode 100644 index 5af5e26e2d0..00000000000 Binary files a/getting_started/first_3d_game/img/02.player_input/07.input_map_tab.png and /dev/null differ diff --git a/getting_started/first_3d_game/img/02.player_input/07.project_settings.png b/getting_started/first_3d_game/img/02.player_input/07.project_settings.png deleted file mode 100644 index 1b9bc8fc10e..00000000000 Binary files a/getting_started/first_3d_game/img/02.player_input/07.project_settings.png and /dev/null differ diff --git a/getting_started/first_3d_game/img/02.player_input/08.actions_list_empty.png b/getting_started/first_3d_game/img/02.player_input/08.actions_list_empty.png deleted file mode 100644 index 664a2d1ec07..00000000000 Binary files a/getting_started/first_3d_game/img/02.player_input/08.actions_list_empty.png and /dev/null differ diff --git a/getting_started/first_3d_game/img/02.player_input/09.keyboard_key_popup.png b/getting_started/first_3d_game/img/02.player_input/09.keyboard_key_popup.png deleted file mode 100644 index 527e667674f..00000000000 Binary files a/getting_started/first_3d_game/img/02.player_input/09.keyboard_key_popup.png and /dev/null differ diff --git a/getting_started/first_3d_game/img/02.player_input/09.keyboard_keys.png b/getting_started/first_3d_game/img/02.player_input/09.keyboard_keys.png deleted file mode 100644 index 213a9688c4b..00000000000 Binary files a/getting_started/first_3d_game/img/02.player_input/09.keyboard_keys.png and /dev/null differ diff --git a/getting_started/first_3d_game/img/02.player_input/12.move_inputs_mapped.webp b/getting_started/first_3d_game/img/02.player_input/12.move_inputs_mapped.webp deleted file mode 100644 index 4c834a0decb..00000000000 Binary files a/getting_started/first_3d_game/img/02.player_input/12.move_inputs_mapped.webp and /dev/null differ diff --git a/getting_started/first_3d_game/img/02.player_input/13.joy_button_option.webp b/getting_started/first_3d_game/img/02.player_input/13.joy_button_option.webp deleted file mode 100644 index 63b83a5e982..00000000000 Binary files a/getting_started/first_3d_game/img/02.player_input/13.joy_button_option.webp and /dev/null differ diff --git a/getting_started/first_3d_game/img/02.player_input/14.add_jump_button.png b/getting_started/first_3d_game/img/02.player_input/14.add_jump_button.png deleted file mode 100644 index fefa95495af..00000000000 Binary files a/getting_started/first_3d_game/img/02.player_input/14.add_jump_button.png and /dev/null differ diff --git a/getting_started/first_3d_game/img/02.player_input/14.jump_input_action.webp b/getting_started/first_3d_game/img/02.player_input/14.jump_input_action.webp deleted file mode 100644 index 54c1f8d2bcb..00000000000 Binary files a/getting_started/first_3d_game/img/02.player_input/14.jump_input_action.webp and /dev/null differ diff --git a/getting_started/first_3d_game/img/02.player_input/actions_list_empty.webp b/getting_started/first_3d_game/img/02.player_input/actions_list_empty.webp new file mode 100644 index 00000000000..21ca06343ff Binary files /dev/null and b/getting_started/first_3d_game/img/02.player_input/actions_list_empty.webp differ diff --git a/getting_started/first_3d_game/img/02.player_input/add_capsuleshape3d.webp b/getting_started/first_3d_game/img/02.player_input/add_capsuleshape3d.webp index 7f9ed5eb6d6..e8dd53983bd 100644 Binary files a/getting_started/first_3d_game/img/02.player_input/add_capsuleshape3d.webp and b/getting_started/first_3d_game/img/02.player_input/add_capsuleshape3d.webp differ diff --git a/getting_started/first_3d_game/img/02.player_input/add_character_body3D.webp b/getting_started/first_3d_game/img/02.player_input/add_character_body3D.webp index 6e0487956ec..ce348d6e5a9 100644 Binary files a/getting_started/first_3d_game/img/02.player_input/add_character_body3D.webp and b/getting_started/first_3d_game/img/02.player_input/add_character_body3D.webp differ diff --git a/getting_started/first_3d_game/img/02.player_input/adding_action.webp b/getting_started/first_3d_game/img/02.player_input/adding_action.webp new file mode 100644 index 00000000000..686a0ab04f5 Binary files /dev/null and b/getting_started/first_3d_game/img/02.player_input/adding_action.webp differ diff --git a/getting_started/first_3d_game/img/02.player_input/adding_node3D.webp b/getting_started/first_3d_game/img/02.player_input/adding_node3D.webp index c0c20d768ae..df238572cbb 100644 Binary files a/getting_started/first_3d_game/img/02.player_input/adding_node3D.webp and b/getting_started/first_3d_game/img/02.player_input/adding_node3D.webp differ diff --git a/getting_started/first_3d_game/img/02.player_input/input_map_tab.webp b/getting_started/first_3d_game/img/02.player_input/input_map_tab.webp new file mode 100644 index 00000000000..90d545c377f Binary files /dev/null and b/getting_started/first_3d_game/img/02.player_input/input_map_tab.webp differ diff --git a/getting_started/first_3d_game/img/02.player_input/instantiating_the_model.webp b/getting_started/first_3d_game/img/02.player_input/instantiating_the_model.webp new file mode 100644 index 00000000000..3ef8b863177 Binary files /dev/null and b/getting_started/first_3d_game/img/02.player_input/instantiating_the_model.webp differ diff --git a/getting_started/first_3d_game/img/02.player_input/joy_button_option.webp b/getting_started/first_3d_game/img/02.player_input/joy_button_option.webp new file mode 100644 index 00000000000..409fc2603bf Binary files /dev/null and b/getting_started/first_3d_game/img/02.player_input/joy_button_option.webp differ diff --git a/getting_started/first_3d_game/img/02.player_input/joystick_axis_input.webp b/getting_started/first_3d_game/img/02.player_input/joystick_axis_input.webp index 3fe3689b642..067d3ca3c1c 100644 Binary files a/getting_started/first_3d_game/img/02.player_input/joystick_axis_input.webp and b/getting_started/first_3d_game/img/02.player_input/joystick_axis_input.webp differ diff --git a/getting_started/first_3d_game/img/02.player_input/jump_input_action.webp b/getting_started/first_3d_game/img/02.player_input/jump_input_action.webp new file mode 100644 index 00000000000..2ece7bfd4ba Binary files /dev/null and b/getting_started/first_3d_game/img/02.player_input/jump_input_action.webp differ diff --git a/getting_started/first_3d_game/img/02.player_input/keyboard_keys.webp b/getting_started/first_3d_game/img/02.player_input/keyboard_keys.webp new file mode 100644 index 00000000000..af3e19e6ad5 Binary files /dev/null and b/getting_started/first_3d_game/img/02.player_input/keyboard_keys.webp differ diff --git a/getting_started/first_3d_game/img/02.player_input/left_inputmap.webp b/getting_started/first_3d_game/img/02.player_input/left_inputmap.webp index e66d74c2af4..3c23e4ad2ed 100644 Binary files a/getting_started/first_3d_game/img/02.player_input/left_inputmap.webp and b/getting_started/first_3d_game/img/02.player_input/left_inputmap.webp differ diff --git a/getting_started/first_3d_game/img/02.player_input/left_joystick_select.webp b/getting_started/first_3d_game/img/02.player_input/left_joystick_select.webp deleted file mode 100644 index 2411570b106..00000000000 Binary files a/getting_started/first_3d_game/img/02.player_input/left_joystick_select.webp and /dev/null differ diff --git a/getting_started/first_3d_game/img/02.player_input/move_inputs_mapped.webp b/getting_started/first_3d_game/img/02.player_input/move_inputs_mapped.webp new file mode 100644 index 00000000000..3f75f1579ee Binary files /dev/null and b/getting_started/first_3d_game/img/02.player_input/move_inputs_mapped.webp differ diff --git a/getting_started/first_3d_game/img/02.player_input/05.moving_the_sphere_up.png b/getting_started/first_3d_game/img/02.player_input/moving_the_sphere_up.png similarity index 100% rename from getting_started/first_3d_game/img/02.player_input/05.moving_the_sphere_up.png rename to getting_started/first_3d_game/img/02.player_input/moving_the_sphere_up.png diff --git a/getting_started/first_3d_game/img/02.player_input/new_scene.webp b/getting_started/first_3d_game/img/02.player_input/new_scene.webp new file mode 100644 index 00000000000..3f72d5effb9 Binary files /dev/null and b/getting_started/first_3d_game/img/02.player_input/new_scene.webp differ diff --git a/getting_started/first_3d_game/img/02.player_input/project_settings.webp b/getting_started/first_3d_game/img/02.player_input/project_settings.webp new file mode 100644 index 00000000000..b142e31830b Binary files /dev/null and b/getting_started/first_3d_game/img/02.player_input/project_settings.webp differ diff --git a/getting_started/first_3d_game/img/02.player_input/scene_structure.webp b/getting_started/first_3d_game/img/02.player_input/scene_structure.webp new file mode 100644 index 00000000000..0bad10cf569 Binary files /dev/null and b/getting_started/first_3d_game/img/02.player_input/scene_structure.webp differ diff --git a/getting_started/first_3d_game/img/02.player_input/04.sphere_shape.png b/getting_started/first_3d_game/img/02.player_input/sphere_shape.png similarity index 100% rename from getting_started/first_3d_game/img/02.player_input/04.sphere_shape.png rename to getting_started/first_3d_game/img/02.player_input/sphere_shape.png diff --git a/getting_started/first_3d_game/img/02.player_input/toggling_visibility.webp b/getting_started/first_3d_game/img/02.player_input/toggling_visibility.webp new file mode 100644 index 00000000000..f2d395d1474 Binary files /dev/null and b/getting_started/first_3d_game/img/02.player_input/toggling_visibility.webp differ