I am doing a small project about a battle on spaceships (3d). You need to add a marker / compass at the top of the screen that will point to the origin.
Problem getting the angle between the direction of the spaceship and the direction to the origin of the coordinate.
We need an angle only along the axis, as if it were a top view.
var ang = rad2deg(Vector2(1,0).rotated(rotation.y).angle_to(-Vector2(global_transform.origin.x, global_transform.origin.z)))
ang = clamp(ang, -45, 45)