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 7cf58c3d4..3f778d2e0 100644 --- a/getting_started/first_3d_game/03.player_movement_code.rst +++ b/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) diff --git a/getting_started/first_3d_game/07.killing_player.rst b/getting_started/first_3d_game/07.killing_player.rst index 58af3b168..462e8674d 100644 --- a/getting_started/first_3d_game/07.killing_player.rst +++ b/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) diff --git a/getting_started/first_3d_game/09.adding_animations.rst b/getting_started/first_3d_game/09.adding_animations.rst index 5d1269705..0df813077 100644 --- a/getting_started/first_3d_game/09.adding_animations.rst +++ b/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