From e289b9263b3cf0226cabf3a95a0000ad8de56eb3 Mon Sep 17 00:00:00 2001 From: nnate1 Date: Tue, 1 Apr 2025 21:26:34 +0100 Subject: [PATCH] [First 3D Game] update Pivot.look_at to Pivot.basis, follow up to 2954936 --- getting_started/first_3d_game/03.player_movement_code.rst | 2 ++ getting_started/first_3d_game/07.killing_player.rst | 6 ++++-- getting_started/first_3d_game/09.adding_animations.rst | 6 ++++-- 3 files changed, 10 insertions(+), 4 deletions(-) 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 a1fc2d561..18f113cc6 100644 --- a/getting_started/first_3d_game/03.player_movement_code.rst +++ b/getting_started/first_3d_game/03.player_movement_code.rst @@ -274,6 +274,7 @@ Here is the complete ``player.gd`` code for reference. if direction != Vector3.ZERO: direction = direction.normalized() + # Setting the basis property will affect the rotation of the node. $Pivot.basis = Basis.looking_at(direction) # Ground Velocity @@ -327,6 +328,7 @@ Here is the complete ``player.gd`` code for reference. if (direction != Vector3.Zero) { direction = direction.Normalized(); + // Setting the basis property will affect the rotation of the node. GetNode("Pivot").Basis = Basis.LookingAt(direction); } diff --git a/getting_started/first_3d_game/07.killing_player.rst b/getting_started/first_3d_game/07.killing_player.rst index 92a0a65b8..f29363f6f 100644 --- a/getting_started/first_3d_game/07.killing_player.rst +++ b/getting_started/first_3d_game/07.killing_player.rst @@ -349,7 +349,8 @@ Finally, the longest script, ``player.gd``: # Prevent diagonal moving fast af if direction != Vector3.ZERO: direction = direction.normalized() - $Pivot.look_at(position + direction, Vector3.UP) + # Setting the basis property will affect the rotation of the node. + $Pivot.basis = Basis.looking_at(direction) # Ground Velocity target_velocity.x = direction.x * speed @@ -450,7 +451,8 @@ Finally, the longest script, ``player.gd``: if (direction != Vector3.Zero) { direction = direction.Normalized(); - GetNode("Pivot").LookAt(Position + direction, Vector3.Up); + // Setting the basis property will affect the rotation of the node. + GetNode("Pivot").Basis = Basis.LookingAt(direction); } // Ground Velocity diff --git a/getting_started/first_3d_game/09.adding_animations.rst b/getting_started/first_3d_game/09.adding_animations.rst index 38ae7f8aa..96d15d33c 100644 --- a/getting_started/first_3d_game/09.adding_animations.rst +++ b/getting_started/first_3d_game/09.adding_animations.rst @@ -342,7 +342,8 @@ Here's the *Player* script. # Prevent diagonal movement being very fast if direction != Vector3.ZERO: direction = direction.normalized() - $Pivot.look_at(position + direction,Vector3.UP) + # Setting the basis property will affect the rotation of the node. + $Pivot.basis = Basis.looking_at(direction) $AnimationPlayer.speed_scale = 4 else: $AnimationPlayer.speed_scale = 1 @@ -448,7 +449,8 @@ Here's the *Player* script. if (direction != Vector3.Zero) { direction = direction.Normalized(); - GetNode("Pivot").LookAt(Position + direction, Vector3.Up); + // Setting the basis property will affect the rotation of the node. + GetNode("Pivot").Basis = Basis.LookingAt(direction); GetNode("AnimationPlayer").PlaybackSpeed = 4; } else