#How to calculate the angle on y-axis to navigation path direction?
1 messages · Page 1 of 1 (latest)
First get a vector to where the armature is facing, then use signed_angle_to() to specify over which axis to rotate and to where:
#May be -global_basis.z instead, can't remember.
var facing: Vector3 = global_basis.z
var target_pos: Vector3 = navigation_agent.get_next_path_position()
var facing_target: Vector3 = global_position.direction_to(target_pos)
#Only over the Y axis, a.k.a UP.
var rotation_y: float = facing.signed_angle_to(facing_target, Vector3.UP)
global_rotation.y += rotation_y
I have not tested it for the record. But using vector methods is way easier than manually calculating the angle.