Public Group

# Target Tracking

This topic is 4173 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## 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 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.

1. 1
2. 2
3. 3
Rutin
19
4. 4
khawk
14
5. 5
frob
12

• 9
• 11
• 11
• 23
• 12
• ### Forum Statistics

• Total Topics
633657
• Total Posts
3013198
×