It was not until I started making video games seriously (and professionally) that I found a reason for any of the math they were trying to put into my head.
Luckily, due to the fact that I am not an idiot (in grade 9 when I actually did do my homework, I got a 100% in Geometry, having never missed a single answer on any homework, test or final; something never done before in my school’s history), I was able to catch up on most of all that math on my own, but finally I have created an equation that suits a physical model I also designed, but I am still not at the mathematical level needed to actually solve it.
Now I am the CTO of a game company in Tokyo and I need this solved (that is, better than my guess-and-check iterative method, which does work, but is too slow).
Without further ado:
Tp = target position.Tv = target velocity.Ta = target acceleration.Bp = bullet position (when originally fired).Bs = bullet speed.length² = A²+B²+C² in 3D.length²((Tp+Tvt+½×Tat²)-Bp) = (Bs*Bs)or:length²((Tp+Tvt+½×Tat²)-Bp)-(Bs*Bs) = 0Solve for t (time)
The keen observer can see a target moving along a trajectory and a bullet moving as well.
But this is not how to intercept the bullet with the target. As you can see, the direction of the bullet does not matter.
Bullet velocity is not a factor, it is the bullet speed.
This will ultimately be used in the game engine being developed in my company to allow bots to aim at targets.
Here, however, I am not interested in aiming a bot at a target; this equation requires that you solve for t, while the actual direction of the bullet to be fired is unknown.
I will also include this in an upcoming article on game AI and I will give credits to whoever can solve this (please show your work so that I can include an explanation of each step in the article).
Note: I already know how to solve this using iterative methods in C++. I already have bots that are devastatingly accurate (you have a 100% chance of being hit unless you manually change your own trajectory while the bullet is traveling). But when there are too many bots, the engine slows unacceptably. This equation correctly describes the same thing I am performing iteratively, so by solving for t in the equations above I hope I can increase the efficiency of the bot AI dramatically.
Thank you,
L. Spiro