So I’ve got a working missile using augmented proportional navigation.
However, I’m trying to incorporate the option to put the missile into a ballistic trajectory in anticipation of an unpowered missile stage.
In this case, I can’t use APN anymore, as a ballistic intercept requires the use of a linear intercept as a part of the calculation.
Now, in the case of dumb projectiles, linear intercept is pretty straight forward. You just need the shooter position, shooter velocity, target position, target velocity, and projectile speed.
But for a missile, some complications are introduced into the problem, because the shooter speed and shot speed are the same thing, and some care must be taken to separate the two.
Because the missile rigidbody doesn’t change direction instantly, you get some slide. Because of this, using the missile velocity as the shot speed becomes incorrect, since any portion of velocity not heading towards the target becomes an overestimation of the missile speed leading to undershoot.
So the solution seems to be getting the portion of the velocity headed towards the target and using that as the shot speed. Then subtracting that portion from the missile velocity to use as the current shooter velocity.
// Find the portion of velocity headed towards the target
Vector3 shotVelocity = Vector3.Project( missileRigidbody.velocity, target.position - transform.position );
// Subtract that portion of the missile's velocity when figuring shooter speed
Vector3 missileVelocity = missileRigidbody.velocity - shotVelocity;
It looks pretty straight forward, but the missile is still overestimating its speed with regard to intercept.
I’m not sure where my reasoning is flawed.
Any insight?