Browse Source

Rename move actions and improve code block in 3d tutorial

Nathan Lovato 4 years ago
parent
commit
a6bd1de290

+ 2 - 2
getting_started/first_3d_game/02.player_input.rst

@@ -94,8 +94,8 @@ can bind keys to these actions.
 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.
 
-We're going to name our actions ``move_left``, ``move_right``, ``move_up``,
-``move_down``, and ``jump``.
+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.
 

+ 15 - 14
getting_started/first_3d_game/03.player_movement_code.rst

@@ -51,11 +51,11 @@ using the global ``Input`` object, in ``_physics_process()``.
            direction.x += 1
        if Input.is_action_pressed("move_left"):
            direction.x -= 1
-       if Input.is_action_pressed("move_down"):
+       if Input.is_action_pressed("move_back"):
            # Notice how we are working with the vector's x and z axes.
            # In 3D, the XZ plane is the ground plane.
            direction.z += 1
-       if Input.is_action_pressed("move_up"):
+       if Input.is_action_pressed("move_forward"):
            direction.z -= 1
 
 Here, we're going to make all calculations using the ``_physics_process()``
@@ -112,17 +112,18 @@ fall speed separately. Be sure to go back one tab so the lines are inside the
 
 ::
 
-       #if direction.length() > 0:
-           #direction = direction.normalized()
-           #$Pivot.look_at(translation + direction, Vector3.UP)
+    func _physics_process(delta):_
+        #...
+        if direction.length() > 0:
+            #...
 
-       # Ground velocity
-       velocity.x = direction.x * speed
-       velocity.z = direction.z * speed
-       # Vertical velocity
-       velocity.y -= fall_acceleration * delta
-       # Moving the character
-       velocity = move_and_slide(velocity, Vector3.UP)
+        # Ground velocity
+        velocity.x = direction.x * speed
+        velocity.z = direction.z * speed
+        # Vertical velocity
+        velocity.y -= fall_acceleration * delta
+        # Moving the character
+        velocity = move_and_slide(velocity, Vector3.UP)
 
 For the vertical velocity, we subtract the fall acceleration multiplied by the
 delta time every frame. Notice the use of the ``-=`` operator, which is a
@@ -171,9 +172,9 @@ Here is the complete ``Player.gd`` code for reference.
            direction.x += 1
        if Input.is_action_pressed("move_left"):
            direction.x -= 1
-       if Input.is_action_pressed("move_down"):
+       if Input.is_action_pressed("move_back"):
            direction.z += 1
-       if Input.is_action_pressed("move_up"):
+       if Input.is_action_pressed("move_forward"):
            direction.z -= 1
 
        if direction.length() > 0:

+ 2 - 2
getting_started/first_3d_game/07.killing_player.rst

@@ -207,9 +207,9 @@ Finally, the longest script, ``Player.gd``.
            direction.x += 1
        if Input.is_action_pressed("move_left"):
            direction.x -= 1
-       if Input.is_action_pressed("move_down"):
+       if Input.is_action_pressed("move_back"):
            direction.z += 1
-       if Input.is_action_pressed("move_up"):
+       if Input.is_action_pressed("move_forward"):
            direction.z -= 1
 
        if direction.length() > 0:

+ 2 - 2
getting_started/first_3d_game/09.adding_animations.rst

@@ -273,9 +273,9 @@ Here's the *Player* script.
            direction.x += 1
        if Input.is_action_pressed("move_left"):
            direction.x -= 1
-       if Input.is_action_pressed("move_down"):
+       if Input.is_action_pressed("move_back"):
            direction.z += 1
-       if Input.is_action_pressed("move_up"):
+       if Input.is_action_pressed("move_forward"):
            direction.z -= 1
 
        if direction.length() > 0: