Target Tracking

Started by
0 comments, last by Captain P 16 years, 10 months ago
I was developing an asteroids-ish clone a while back and have gone back to it, I ended up deleting a load of the code and starting over as it seemed like the best approach. At the moment I'm working on basic elements, target tracking, chasing an object etc etc one by one. As the title suggests I'm working on target tracking. The method I'm initially using to test this is to have one ship in the centre of the screen and another one at another point then have it decide if it should rotate left or right then stop when it is pointing directly at it. But... I'm very stuck. What are some of the methods of determining an objects position relative to another? I was reading about and it came up that I could use the dot product to give a value between -1 and 1 but what kind of information would i need to have access to, to perform this calculation? I think the code I had before took the ships x,y positon and compared it to an objects position, however this does not take into account the direction the ship is facing. hmm I think that all makes sense :p thanx
I'm sorry your witty comment could not be loaded.
Advertisement
With a little basic vector math, this shouldn't be difficult. Substract your objects position from the targets position, and you get the targets relative position. So how would you make your object face the target? By keeping a direction vector for your object. Compare their orientation, and adjust your objects direction vector untill it has the same angle as the targets relative position vector. Of course, you can also use a simple angle value for your object instead of a direction vector, if you wish.
Create-ivity - a game development blog Mouseover for more information.

This topic is closed to new replies.

Advertisement