double speed = distance / ((double)deceleration * decelerationTweaker); speed = Math.Min(speed, MaxSpeed); Vector2 desiredVelocity = toTarget * speed / distance; return desiredVelocity - Velocity;
This is fishy. Notice how speed is proportional to distance, but then it gets divided by distance. This means your desiredVelocity is simply toTarget / some_constant. The resulting dynamics are those of an undamped pendulum, so of course you get oscillatory behavior. I don't have the book in front of me to compare the code, but that can't be what they are doing.