How to get rotation Z (0 to -/+180) values using look_at?

Godot Version



I have an arrow pointing to -z direction with camera top down view. By using look_at() I could get angle between arrow and player like this

@onready var player = $Player
@onready var node3D = $Area3D/Node3D

func _process(delta):

It returns arrow’s rotation Y values between 0 to +/-180 when the player walks around it.

But when I tried doing this side way this codes no longer produce 0 to +/-180 values. eg.

func _process(delta):

How can I get those values when I have my arrow side way and camera with front view? I tried playing with arrow rotations/direction and Look_at Vectors but could not reproduce those same values.
Thank you.

With euler rotations you need to change order of the axes to get different ranges in the rotation property.

1 Like

var angle = Vector3.RIGHT.signed_angle_to(node3D.global_basis.z, Vector3.BACK)

got answer from another forum.

1 Like