2D Arrow pointing at 3D Position

This is probably a really stupid, easy to solve problem. It feels like one of these things where you lack a fresh perspective or the programming vocab to pull it off; So here’s my Problem:

For my GUI I have a 2D Arrow in 3D Space that is supposed to rotate on its Y-axis to point at a 3D Object. I’m not struggling with the mental model on this, just the execution has escaped me for the past week. Here’s the Arrow:

alt text

This is the hierarchy its in:

alt text

Control being the player’s GameObject.
Basically this is how I thought to do it: Transpose the position into local space using InverseTransformPoint, then use Math.Atan2 to calculate the angle. That doesn’t work and I don’t understand why.


 tmpVector = arrow.InverseTransformPoint(objectToPointAt.position);
 arrow.localEulerAngles = new Vector3(0, Mathf.Atan2(tmpVector.y, tmpVector.z) * Mathf.Rad2Deg, 0);

Thanks in advance for any hints!

As I expected, the answer was actually right in Front of me all the time. I needed to add 180 to realign the arrow.


tmpVector = player.transform.InverseTransformPoint(allyIsland.position); // Transfer the point into the local space of the arrow
angleToTarget = Mathf.Atan2(tmpVector.x, tmpVector.z) * Mathf.Rad2Deg; // Calculate the Angle the arrow needs to rotate
angleToTarget += 180.0f; // Add 180 Degrees
guiAllyIslandDir.localEulerAngles = new Vector3(0, angleToTarget, 0); // Rotate!

Thanks, everyone! Here’s where I feel really dumb ^^