0

Some real-time strategy games, notably Total Annihilation and Supreme Commander among others, have simulated projectiles that travel along realistic-looking parabolic arcs to reliably hit moving targets. I am trying to create a game which does this too, and I am looking for advice on how to do it.

So far, I found a solution to the mathematical problem online, but it involves solving a quartic equation. Every quartic solver function I have found online is either incorrect or numerically unstable. I also tried to derive a solution myself, and I reached the point where I would need to find the intersection of two complicated trigonometric equations, which is arguably even harder and more cpu-hungry. Moreover, I tried an iterative method without success (but it is possible I simply don't know how to code it correctly). But since the aforementioned games and others exist, there clearly must be an efficient way to solve this problem and I wonder if someone who knows could explain how it is done.

To recap: the goal is to find a launch vector for a projectile to reliably hit a target moving at constant velocity, given an initial projectile speed and constant downward-pointing gravity, and to do it simply and robustly, because many projectiles will need to be simulated. Do games really implement quartic solvers to do this? If so, can someone point to one that actually works? If not, what is the method I should use instead?

0 Answers0