I'm trying to implement the simplest possible form of proportional navigation, i.e, the missile turns in the direction that its bearing-to-target is changing, and once its bearing-to-target is unchanging, it's on an intercept course.
So, I have a 2d missile moving at a constant speed in the direction it is facing, which can turn at a constant rate, and every interval I update the missile with something like:
Position += VectorProduct (Direction * Speed * TimePassed)
PreviousTargetBearing = TargetBearing
TargetBearing = AngleBetween(TargetPosition, Position)
TargetBearingDelta = TargetBearing - PreviousTargetBearing
If TargetBearingDelta > 0: MissileDirection += TurnRate * TimePassed
If TargetBearingDelta < 0: MissileDirection -= TurnRate * TimePassed
Problem is, the missile always oscillates around its launch direction, because as soon as the missile turns the first time, this reverses the sign of TargetBearingDelta, making it then turn in the opposite direction, and so on...
What is the simplest way I can resolve this problem? I'm sure I'm missing something simple.
Related StackOverflow question: How to create an “intercept missile” for a game?
To reiterate, I am interested specifically in implementing the proportional navigation algorithm, not in homing algorithms in general.
Update: I guess the obvious answer is to not check bearing and adjust heading every turn, but to alternate between the two. I'll try that.