Sign in to follow this  
SiS-Shadowman

Movement prediction

Recommended Posts

I'm currently writing code that controls a rocket in order to hit a (possibly) moving/accelerating target. I'm aiming for a newtonian solution: the rocket applies forces in whatever direction possible & necessary in order to fly to the target. This works fine for a stationary target but fails when the target is moving: It can't yet predict where the target would be and thus won't directly hit the target when flying perpendicular to it. Instead it would fly behind the target and hit it then.

I've tried to come up with a solution that doesn't involve some step-by-step simulation because that would probably be overkill for a game. Instead I reduced the problem from 3 dimensions to 1.



I simply assume both A and B are flying in the same direction.
Since I know distance, velocity and acceleration of both, I can solve the following equation for t and then calculate the probable position of A in 3 dimensional space again.





What do you think of this solution? Do you have an alternative approach that might give better (more accurate) results?

*edit2*
I have found out that projection the target's velocity onto the dotted line seems to result in a better overall accuracy. I think I'll keep this one until I found a better solution.

*edit*
Corrected P(A)
Fixed Picture link

[Edited by - SiS-Shadowman on September 28, 2010 3:51:43 PM]

Share this post


Link to post
Share on other sites
Have you looked into PID (Proportional Integral Derivative) methods? I recently read in AI Game Programming Wisdom 2 about PID controllers, and the example the author uses is of a missile trying to hit a target.

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