equation for determining vector's angle
I''m trying to develop an ai to follow another entity in a 2d environment. What is the equation for figuring out the angle the ship needs to face to follow another ship? im sorry i cant articulate this better, so i hope someone understands what i mean.
brian
Brian J
A is target
B is your ship
forward is the direction your ship is facing right now
AB=a-b
normalize
cos=dot(AB,forward)
angle=acos(cos)*180/PI
you need to do it in xy and yz plane to find out the yaw and pitch
B is your ship
forward is the direction your ship is facing right now
AB=a-b
normalize
cos=dot(AB,forward)
angle=acos(cos)*180/PI
you need to do it in xy and yz plane to find out the yaw and pitch
http://www.8ung.at/basiror/theironcross.html
Things get a bit more complicated if you want to try to "head off" your opponent. However, it comes down to the old "what angle do you shoot a bullet at to hit another bullet?" question, which has been answered many times on the Math and Physics forum (and occasionally on the AI one), so check those old posts out. Just "aim ahead" at each timestep!
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement