So I am trying to write some code to allow for calculating the intercept point of a “missile” in 3D space. Basically I want to be in a space ship and be able to place a targeting marker for where to shoot to hit another ship that could be flying in an ever growing corkscrew in 3D space. Now obviously I cannot account for changes in the other pilots course, but if they maintain their rate of rotational and forward acceleration I should be able to predict where they will be. I am just at a loss for the math. Can anyone help?
Haven’t coded anything remotely related to missile aiming myself, but still:
If you want to stay away from scary math, you could do it in approximations.
First, you get distance from ship to target. Knowing missile speed, you approximate how long it will take it to reach the target. From this time figure, you can estimate expected position of the target for the missile flight time, using target’s velocity vector, and maybe even rate of change of this vector in time, if you want to account for acceleration.
Now, you get a distance from the new estimated target position and the ship. Calculate missile flight time for this distance.
Then again, estimate target’s position using newly calculated flight time.
Repeat this process several times. The more repeats, the more precise position you will get.
That is it for calculating leading for your target. Works equally good for unguided missiles and projectiles.
As for homing missiles, well you have really a lot of options here. You can look at real world examples.
The simplest to implement would be pursuit guidance. At set intervals of time(missile blueprint tick for example), you would calculate required rotation to point missile velocity vector onto the target, and rotate by this angle, while not forgetting to add constraints for missile characteristics, so it would not be able to turn more than set angle for a given time period.
For other methods, read up on the wiki article in the link.