Not to be spammy, (Andy already posted about this in our
Solaro DevLog) but I figured this would be more visible under tutorials as well.
Just about everybody who’s played a shooting game knows about leading the target. For instance, in Halo, rockets move pretty slow compared to bullets. To get good at the game, you have to learn how far ahead of your target to fire the rockets so they will run into the rocket’s path just as it gets to them.
This isn’t an easy skill to learn as a player, so how do you implement it so that AI players can do it too? It’s easiest to think of this problem in relative positions and velocities. This puts the firing point at the origin and the relative motion of the target is a line. This is of course assuming that the target isn’t changing direction or accelerating.
...
Read the rest (including example code) on our
blog!