Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.
Rotating an object to face another Object
Im trying to build an autopilot or AI into my ships. To do this I need the ships to be able to calculate where they need to turn to and then do it. Ie they have to steer themselves so they are facing another ship. Currently I caluclate how far off I am (in radians) on the xz plane and then rotate by that amount on the y axis. Then I caluclate how far off I am on the xy plane and rotate about the z axis. (as I use the x axis as the front of my ship). This seems to work most of the time although occaisionally it doesnt quite work. But if I execute it a couple times in a row it always works. Just wondering if there is a better way to do this.
0 · ·