I was pulling my hair about this same thing a couple of days ago and finally came up with something that works. I'm sure there is a more elegant way to do it though.

Basically I get the horizontal and vertical angles to the target and from that I calculate yaw and pitch inputs that I feed to the physics engine. It's a bit complicated but I get the vector to the target and my heading vector, construct a couple of shortest arc quaternions and get the angles from them.

I haven't dug into the path finding subject really but that's more about how to get computer controlled characters to find a way from point A to point B, avoiding obstacles and such. This may sound like what a missile is doing too, going from point A to point B but it's not really the same thing. In the case of a missile you know where the target is and it usually goes straight to it. It doesn't try to avoid obstacles.

The problem with a missile is how to make it steer towards the target in a 3D environment and I solved it as I described above. I find out how much off course I am (the angles) and then try to minimize those angles.

I haven't found a ready made solution to the problem so I had to combine several things like getting the direction to the target, my direction, getting the angles for how much I'm off and then steer in the opposite direction to minimize the difference.

Quote:Originally posted by KenD
The problem with a missile is how to make it steer towards the target in a 3D environment and I solved it as I described above. I find out how much off course I am (the angles) and then try to minimize those angles.
KenD

Ok I know how to make the vectors work with an angle, but what is the formula to find the minimum angle?

A simpler, probably faster (yet less precise) way to do this is to create a vector which represents the velocity of the missile. Then get the distance (use the fast formula by not calling sqrt, the squared distance is fine for comparison) for the missile to the target if the missile continues on the same path. Next, get the distance from the target if the missile turns to clockwise this turn, and also if the missile turns counter-clockwise this turn. The distance which is the shortest is the one which the missile should do (ie if turning left shortens the distance to the target, then do that). One side effect of this is that if the turn value is too large, the missile may orbit around the target. :-)

Another method which is better than the one proposed, yet more complicated, is to use quaternions and do linear interpolation between them. This, I believe, produces the best results.

In either case, if your game calls for having lots of missiles, you'll not be very optimized if you call any of the trig math functions (like atan). However, if you only have a couple it probably won't matter.

I think I'm going to stick with what works for now. What you suggested in the first paragraph sounds almost exactly like what I'm doing now. Also I'll probably only use 2 or 3 at a time since the missiles seek out the player immediately on launch, and they go pretty fast too.