mirror of
https://github.com/godotengine/godot-docs.git
synced 2025-12-31 17:49:03 +03:00
Merge pull request #10829 from NNate1/getting-started-3d-game-character-consistent-orientation
[First 3D Game] Update player script recaps to use `Basis.looking_at()`
This commit is contained in:
@@ -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<Node3D>("Pivot").Basis = Basis.LookingAt(direction);
|
||||
}
|
||||
|
||||
|
||||
@@ -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<Node3D>("Pivot").LookAt(Position + direction, Vector3.Up);
|
||||
// Setting the basis property will affect the rotation of the node.
|
||||
GetNode<Node3D>("Pivot").Basis = Basis.LookingAt(direction);
|
||||
}
|
||||
|
||||
// Ground Velocity
|
||||
|
||||
@@ -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<Node3D>("Pivot").LookAt(Position + direction, Vector3.Up);
|
||||
// Setting the basis property will affect the rotation of the node.
|
||||
GetNode<Node3D>("Pivot").Basis = Basis.LookingAt(direction);
|
||||
GetNode<AnimationPlayer>("AnimationPlayer").PlaybackSpeed = 4;
|
||||
}
|
||||
else
|
||||
|
||||
Reference in New Issue
Block a user