Smoother Quaternion.RotateTowards?

I’m using RotateTowards to have a fighter swoop towards a target, fly past it, and wheel around. It does its job, and works correctly, but I would like to know if there are any tricks to smooth out the abrupt start\stop of the rotations. I can change maxDegreesDelta but any value high enough to turn in a reasonable amount of time still has the abrupt transition from flying straight to rotating.

It sounds like you are rotating with a linear angular speed.

If so, you can use a linear angular acceleration instead e.g.


float maxAngularAcceleration = …;

float maxAngularAccelerationDelta = …;

float Kv = … // tweak parameter

float maxAngularSpeed = …;

float maxAngularSpeedDelta = …;

float Kp = … // tweak parameter

// rotation error

float angleError = …

// current angular acceleration

currentAngularAcceleration += Mathf.Sign(angleError) * maxAngularAccelerationDelta;

currentAngularAcceleration = Clamp(currentAngularAcceleration, -maxAngularAcceleration, maxAngularAcceleration);

// current angular speed

currentAngularSpeed += Kv * Time.deltaTime * currentAngularAcceleration;

currentAngularSpeed = Clamp(currentAngularSpeed , -maxAngularSpeed, maxAngularSpeed);

// delta angle to rotate this frame

currentAngleDelta = Kp * Time.deltaTime * currentAngularSpeed;


You can tweak constants - Kv and Kp - to get the movement you like.
Hope it makes sense