I am working on AR/VR and often find I need to smooth damp rotations. Either to simulate a steady cam. Or to show head up display that won’t be fixed with the user’s rotation but will rather “follow” the gaze trying not to introduce motion sickens.
I often end up with something like:
float eulerXVelocity;
float eulerYVelocity;
float eulerZVelocity;
void Update()
{
var cam = Camera.main.transform;
var currentAngles = this.transform.rotation.eulerAngles;
var targetAngles = cam.rotation.eulerAngles;
var x = Mathf.SmoothDampAngle(currentAngles.x, targetAngles.x, ref eulerXVelocity, 0.3f);
var y = Mathf.SmoothDampAngle(currentAngles.y, targetAngles.y, ref eulerYVelocity, 0.3f);
var z = Mathf.SmoothDampAngle(currentAngles.z, targetAngles.z, ref eulerZVelocity, 0.3f);
this.transform.rotation = Quaternion.Euler(x, y, z);
this.transform.position = cam.transform.position + this.transform.rotation * Vector3.forward;
}
Resolving to Mathf.SmoothDampAngle, but I was kind of expecting something similar to exist on Quaternion or Vector3.SmoothDampAngle.
Am I missing something?