I am writing a target-following script with numerous per-axis settings. Below is the most distilled example I can provide of the rotation portion:
private void Rotate()
{
var _target = Quaternion.LookRotation(Target.position - transform.position, Target.up).eulerAngles;
var _next = transform.eulerAngles;
for (var i = 0; i < 3; i++)
_next[i] = Mathf.LerpAngle(_next[i], _target[i], smoothRotateSpeed[i] * Time.deltaTime);
transform.localRotation = Quaternion.Euler(_next);
}
In the example above, "smoothRotationSpeed" is a Vector3 that applies a different smoothing value to each axis.
Unfortunately, because I am modifying each axis individually, I am running into Gimbal lock issues. How can one avoid or compensate for Gimbal lock without losing per-axis (euler) control?
↧