Browse Source

Update direction comparison

Co-authored-by: [email protected]
Nathan Lovato 4 years ago
parent
commit
f68a6a25c5

+ 3 - 3
getting_started/first_3d_game/03.player_movement_code.rst

@@ -85,7 +85,7 @@ call its ``normalize()`` method.
    #func _physics_process(delta):
        #...
 
-       if direction.length() > 0:
+       if direction != Vector3.ZERO:
            direction = direction.normalized()
            $Pivot.look_at(translation + direction, Vector3.UP)
 
@@ -114,7 +114,7 @@ fall speed separately. Be sure to go back one tab so the lines are inside the
 
     func _physics_process(delta):_
         #...
-        if direction.length() > 0:
+        if direction != Vector3.ZERO:
             #...
 
         # Ground velocity
@@ -177,7 +177,7 @@ Here is the complete ``Player.gd`` code for reference.
        if Input.is_action_pressed("move_forward"):
            direction.z -= 1
 
-       if direction.length() > 0:
+       if direction != Vector3.ZERO:
            direction = direction.normalized()
            $Pivot.look_at(translation + direction, Vector3.UP)
 

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

@@ -212,7 +212,7 @@ Finally, the longest script, ``Player.gd``.
        if Input.is_action_pressed("move_forward"):
            direction.z -= 1
 
-       if direction.length() > 0:
+       if direction != Vector3.ZERO:
            direction = direction.normalized()
            $Pivot.look_at(translation + direction, Vector3.UP)
 

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

@@ -190,7 +190,7 @@ vector, add the following code.
 
    func _physics_process(delta):
        #...
-       #if direction.length() > 0:
+       #if direction != Vector3.ZERO:
            #...
            $AnimationPlayer.playback_speed = 4
        else:
@@ -280,7 +280,7 @@ Here's the *Player* script.
        if Input.is_action_pressed("move_forward"):
            direction.z -= 1
 
-       if direction.length() > 0:
+       if direction != Vector3.ZERO:
            direction = direction.normalized()
            $Pivot.look_at(translation + direction, Vector3.UP)
            $AnimationPlayer.playback_speed = 4