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][1]
This is the hierarchy its in:
![alt text][2] 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.
![alt text][2] 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!
[1]: https://dl.dropbox.com/u/4518040/arrow2.PNG
[2]: https://dl.dropbox.com/u/4518040/hierarchy.PNG