Heya – thanks for that link! Yes that’s kind of what I’m doing. That script orientates an object to “look at” another object but in the y-axis only. I’m trying to do it for both the y-axis (left to right) and also the x-axis (up down). I haven’t actually cracked it yet, but having researched it a bit more I think this would be the principle:
1. Calculate y-axis rotation by “looking down” on the vector from above in 2d, and doing a basic atan2 on the x and z distances (as per Dan’s example above).
2. Now here’s the trick – rotate the vector negatively by the result in the y-axis, so you effectively ‘remove’ this rotation from it.
3. Now you’re free to do the same for the x-axis rotation as you’ve ‘straightened’ the vector up to run flat along the z axis.
That’s the theory anyway, bear in mind I might be totally wrong!. I think it would definitely have its limitations too. I ran out of time on this one to finish it off properly and so did it by hand in the end. If I get round to trying it out I’ll post the results.
Cheers, sCam