Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save SnugglePilot/fd6db950e3a30cd04d89a6dea6b79bce to your computer and use it in GitHub Desktop.
Save SnugglePilot/fd6db950e3a30cd04d89a6dea6b79bce to your computer and use it in GitHub Desktop.
rotTrackingTimeLeft -= Time.deltaTime;
Vector3 eulerAngles = this.transform.rotation.eulerAngles;
eulerAngles.x = Mathf.SmoothDampAngle(eulerAngles.x, targetRotation.eulerAngles.x, ref rotVel.x, rotateTime, Mathf.Infinity, Time.deltaTime);
eulerAngles.y = Mathf.SmoothDampAngle(eulerAngles.y, targetRotation.eulerAngles.y, ref rotVel.y, rotateTime, Mathf.Infinity, Time.deltaTime);
eulerAngles.z = Mathf.SmoothDampAngle(eulerAngles.z, targetRotation.eulerAngles.z, ref rotVel.z, rotateTime, Mathf.Infinity, Time.deltaTime);
if (float.IsNaN(eulerAngles.x) || float.IsNaN (eulerAngles.y) || float.IsNaN (eulerAngles.z)) {
// Woops. I don't know why this is the case. TODO: Find out why and fix later.
//Debug.Log ("1:"+this.transform.rotation.eulerAngles);
//Debug.Log ("2:"+targetRotation.eulerAngles);
// ^^ Always the same?!
} else {
this.transform.rotation = Quaternion.Euler (eulerAngles);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment