From c1c33e7908d6be12bb8d6b9076bdb1d5684a1175 Mon Sep 17 00:00:00 2001 From: Shane Smith Date: Tue, 13 Feb 2024 20:34:16 -0500 Subject: [PATCH] Several improvements to "First 3D Game" tutorial This fixes the "Animation > Copy" issue mentioned in https://github.com/godotengine/godot-docs/issues/6744 (see Step 09, around Line 264) The same issue as above was referenced in https://github.com/godotengine/godot/issues/60848 and the fix was to use the solution by @riidom Also, a reference to a button icon has been changed from "A+" to "A>" per feedback on PR 8460 --- .../first_3d_game/01.game_setup.rst | 2 -- .../first_3d_game/02.player_input.rst | 12 +++---- .../first_3d_game/03.player_movement_code.rst | 21 ++++++------ .../first_3d_game/04.mob_scene.rst | 2 -- .../first_3d_game/05.spawning_mobs.rst | 4 +-- .../first_3d_game/06.jump_and_squash.rst | 2 -- .../first_3d_game/07.killing_player.rst | 7 ++-- .../first_3d_game/08.score_and_replay.rst | 12 +++---- .../first_3d_game/09.adding_animations.rst | 32 ++++++++++++------- .../first_3d_game/going_further.rst | 2 -- getting_started/first_3d_game/index.rst | 1 - 11 files changed, 48 insertions(+), 49 deletions(-) diff --git a/getting_started/first_3d_game/01.game_setup.rst b/getting_started/first_3d_game/01.game_setup.rst index c2343e2d8cb..451a5cfe138 100644 --- a/getting_started/first_3d_game/01.game_setup.rst +++ b/getting_started/first_3d_game/01.game_setup.rst @@ -1,5 +1,3 @@ -:article_outdated: True - .. _doc_first_3d_game_game_area: Setting up the game area diff --git a/getting_started/first_3d_game/02.player_input.rst b/getting_started/first_3d_game/02.player_input.rst index a6ae421c294..acedd169303 100644 --- a/getting_started/first_3d_game/02.player_input.rst +++ b/getting_started/first_3d_game/02.player_input.rst @@ -1,5 +1,3 @@ -:article_outdated: True - .. _doc_first_3d_game_player_scene_and_input: Player scene and input actions @@ -72,12 +70,12 @@ It will be the shape the physics engine uses to collide with the environment, so we want it to better fit the 3D model. Shrink it a bit by dragging the orange dot in the viewport. My sphere has a radius of about ``0.8`` meters. -Then, move the shape up so its bottom roughly aligns with the grid's plane. +Then, move the collision shape up so its bottom roughly aligns with the grid's plane. |image4| -You can toggle the model's visibility by clicking the eye icon next to the -``Character`` or the ``Pivot`` nodes. +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. |image5| @@ -106,7 +104,9 @@ can bind keys to these actions. |image7| Godot projects come with some predefined actions designed for user interface -design, which we could use here. But we're defining our own to support gamepads. +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. We're going to name our actions ``move_left``, ``move_right``, ``move_forward``, ``move_back``, and ``jump``. diff --git a/getting_started/first_3d_game/03.player_movement_code.rst b/getting_started/first_3d_game/03.player_movement_code.rst index 87faac29650..eafe9edf69d 100644 --- a/getting_started/first_3d_game/03.player_movement_code.rst +++ b/getting_started/first_3d_game/03.player_movement_code.rst @@ -1,5 +1,3 @@ -:article_outdated: True - .. _doc_first_3d_game_player_movement: Moving the player with code @@ -10,7 +8,8 @@ part to move the character. Right-click the ``Player`` node and select *Attach Script* to add a new script to it. In the popup, set the *Template* to *Empty* before pressing the *Create* -button. +button. We set it to *Empty* because we want to write our own code for +player movement. |image0| @@ -365,12 +364,14 @@ Adding a camera Let's add the camera next. Like we did with our *Player*\ 's *Pivot*, we're going to create a basic rig. Right-click on the ``Main`` node again and select -*Add Child Node*. Create a new :ref:`Marker3D `, and name it ``CameraPivot``. Select ``CameraPivot`` and add a child node :ref:`Camera3D ` to it. Your scene tree should look like this. +*Add Child Node*. Create a new :ref:`Marker3D `, and name it ``CameraPivot``. +Select ``CameraPivot`` and add a child node :ref:`Camera3D ` to it. +Your scene tree should look similar to this. |image3| -Notice the *Preview* checkbox that appears in the top-left when you have the -*Camera* selected. You can click it to preview the in-game camera projection. +Notice the *Preview* checkbox that appears in the top-left of the 3D view when you +have the *Camera* selected. You can click it to preview the in-game camera projection. |image4| @@ -385,13 +386,13 @@ You can also press :kbd:`Ctrl + 2` (:kbd:`Cmd + 2` on macOS). |image5| -On the bottom view, select your :ref:`Camera3D ` and turn on camera Preview by clicking -the checkbox. +On the bottom view, select your :ref:`Camera3D ` and turn on camera +Preview by clicking the checkbox. |image6| -In the top view, move the camera about ``19`` units on the Z axis (the blue -one). +In the top view, make sure your *Camera3D* is selected and move the camera about +``19`` units on the Z axis (drag the blue arrow). |image7| diff --git a/getting_started/first_3d_game/04.mob_scene.rst b/getting_started/first_3d_game/04.mob_scene.rst index 79198d811a9..62baf7d0669 100644 --- a/getting_started/first_3d_game/04.mob_scene.rst +++ b/getting_started/first_3d_game/04.mob_scene.rst @@ -1,5 +1,3 @@ -:article_outdated: True - .. _doc_first_3d_game_designing_the_mob_scene: Designing the mob scene diff --git a/getting_started/first_3d_game/05.spawning_mobs.rst b/getting_started/first_3d_game/05.spawning_mobs.rst index d5678b8bd53..6b75f07a3b3 100644 --- a/getting_started/first_3d_game/05.spawning_mobs.rst +++ b/getting_started/first_3d_game/05.spawning_mobs.rst @@ -1,5 +1,3 @@ -:article_outdated: True - .. _doc_first_3d_game_spawning_monsters: Spawning monsters @@ -20,6 +18,8 @@ Go to *Project -> Project Settings*. |image1| +If you still have *Input Map* open, switch to the *General* tab. + In the left menu, navigate down to *Display -> Window*. On the right, set the *Width* to ``720`` and the *Height* to ``540``. diff --git a/getting_started/first_3d_game/06.jump_and_squash.rst b/getting_started/first_3d_game/06.jump_and_squash.rst index b85663f7912..1e22476e8ee 100644 --- a/getting_started/first_3d_game/06.jump_and_squash.rst +++ b/getting_started/first_3d_game/06.jump_and_squash.rst @@ -1,5 +1,3 @@ -:article_outdated: True - .. _doc_first_3d_game_jumping_and_squashing_monsters: Jumping and squashing monsters diff --git a/getting_started/first_3d_game/07.killing_player.rst b/getting_started/first_3d_game/07.killing_player.rst index 1449394206a..1210a47cc70 100644 --- a/getting_started/first_3d_game/07.killing_player.rst +++ b/getting_started/first_3d_game/07.killing_player.rst @@ -1,5 +1,3 @@ -:article_outdated: True - .. _doc_first_3d_game_killing_the_player: Killing the player @@ -115,7 +113,7 @@ the character should die when an enemy runs into the collider. Note that without Vector3 playerPosition = GetNode("Player").Position; -gives error because there is no $Player! +gives an error because there is no $Player! Also note that the enemy colliding with the player and dying depends on the size and position of the ``Player`` and the ``Mob``\ 's collision shapes. You may need to move them @@ -152,6 +150,9 @@ Get the timer, and stop it, in the ``_on_player_hit()`` function. If you try the game now, the monsters will stop spawning when you die, and the remaining ones will leave the screen. +Notice also that the game no longer crashes or displays an error when the player dies. Because +we are stopping the MobTimer, it no longer triggers the ``_on_mob_timer_timeout()`` function. + You can pat yourself in the back: you prototyped a complete 3D game, even if it's still a bit rough. diff --git a/getting_started/first_3d_game/08.score_and_replay.rst b/getting_started/first_3d_game/08.score_and_replay.rst index c7ea2f8488e..0037e6447cb 100644 --- a/getting_started/first_3d_game/08.score_and_replay.rst +++ b/getting_started/first_3d_game/08.score_and_replay.rst @@ -1,5 +1,3 @@ -:article_outdated: True - .. _doc_first_3d_game_score_and_replay: Score and replay @@ -12,8 +10,7 @@ We have to keep track of the current score in a variable and display it on screen using a minimal interface. We will use a text label to do that. In the main scene, add a new child node :ref:`Control ` to ``Main`` and name it -``UserInterface``. You will automatically be taken to the 2D screen, where you can -edit your User Interface (UI). +``UserInterface``. Ensure you are on the 2D screen, where you can edit your User Interface (UI). Add a :ref:`Label ` node and name it ``ScoreLabel`` @@ -54,7 +51,8 @@ of how all the built-in UI widgets will look with your theme resource. |image6| -By default, a theme only has one property, the *Default Font*. +By default, a theme only has a few properties: *Default Base Scale*, *Default Font* +and *Default Font Size*. .. seealso:: @@ -62,8 +60,8 @@ By default, a theme only has one property, the *Default Font*. interfaces, but that is beyond the scope of this series. To learn more about creating and editing themes, see :ref:`doc_gui_skinning`. -This one expects a font file like the ones you have on your computer. Two common -font file formats are TrueType Font (TTF) and OpenType Font (OTF). +The *Default Font* expects a font file like the ones you have on your computer. +Two common font file formats are TrueType Font (TTF) and OpenType Font (OTF). In the *FileSystem* dock, expand the ``fonts`` directory and click and drag the ``Montserrat-Medium.ttf`` file we included in the project onto the *Default Font*. diff --git a/getting_started/first_3d_game/09.adding_animations.rst b/getting_started/first_3d_game/09.adding_animations.rst index 104c675c4d4..d99deefed65 100644 --- a/getting_started/first_3d_game/09.adding_animations.rst +++ b/getting_started/first_3d_game/09.adding_animations.rst @@ -1,5 +1,3 @@ -:article_outdated: True - .. _doc_first_3d_game_character_animation: Character animation @@ -45,7 +43,7 @@ time in seconds. We want the animation to start playback automatically at the start of the game. Also, it should loop. -To do so, you can click the button with an "A+" icon in the animation toolbar +To do so, you can click the button with an "A>" icon in the animation toolbar and the looping arrows, respectively. |image5| @@ -104,7 +102,11 @@ timeline. |timeline_05_click| -In the *Inspector*, set the *Position*'s *Y* axis to ``0.65`` meters and the *Rotation*' *X* axis to ``8``. +In the *Inspector*, set the *Position*'s *Y* axis to ``0.65`` meters and the +*Rotation*' *X* axis to ``8``. + +If you don't see the properties in the *Inspector* panel, first click on the +``Character`` node again in the *Scene* dock. |image13| @@ -259,16 +261,22 @@ node structure, you can copy them to different scenes. For example, both the ``Mob`` and the ``Player`` scenes have a ``Pivot`` and a ``Character`` node, so we can reuse animations between them. -Open the *Player* scene, select the AnimationPlayer node and open the "float" -animation. Next, click on **Animation > Copy**. Then open ``mob.tscn``, -create an AnimationPlayer child node and select it. Click **Animation > Paste** -and make sure that the button with an "A+" icon (Autoplay on Load) and the -looping arrows (Animation looping) are also turned on in the animation editor -in the bottom panel. That's it; all monsters will now play the float animation. +Open the *Player* scene, select the AnimationPlayer node and then click on +**Animation > Manage Animations...**. Click the *Copy animation to clipboard* button +(two small squares) alongside the *float* animation. Click OK to close the window. + +Then open ``mob.tscn``, create an :ref:`AnimationPlayer ` child +node and select it. Click **Animation > Manage Animations**, then **Add Library**. You +should see the message "Global library will be created." Leave the text field blank and +click OK. Click the *Paste* icon (clipboard) and it should appear in the window. Click OK +to close the window. + +Next, make sure that the button with an "A>" icon (Autoplay on Load) and the looping +arrows (Animation looping) are also turned on in the animation editor in the bottom panel. +That's it; all monsters will now play the float animation. We can change the playback speed based on the creature's ``random_speed``. Open -the *Mob*'s script and at the end of the ``initialize()`` function, add the -following line. +the *Mob*'s script and at the end of the ``initialize()`` function, add the following line. .. tabs:: .. code-tab:: gdscript GDScript diff --git a/getting_started/first_3d_game/going_further.rst b/getting_started/first_3d_game/going_further.rst index 3ba482ca7ad..5138f213e19 100644 --- a/getting_started/first_3d_game/going_further.rst +++ b/getting_started/first_3d_game/going_further.rst @@ -1,5 +1,3 @@ -:article_outdated: True - .. _doc_first_3d_game_going_further: Going further diff --git a/getting_started/first_3d_game/index.rst b/getting_started/first_3d_game/index.rst index 87bb21297da..05d7b04c7ff 100644 --- a/getting_started/first_3d_game/index.rst +++ b/getting_started/first_3d_game/index.rst @@ -1,5 +1,4 @@ :allow_comments: False -:article_outdated: True .. _doc_your_first_3d_game: