Sign in to follow this  
kaidiez

Target Tracking

Recommended Posts

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

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this