Last active
October 4, 2021 19:42
-
-
Save UtMan88/1a2126e276a07a1bcd3a13069dc569a9 to your computer and use it in GitHub Desktop.
Originally posted by BakonGuy at Unity Answers: https://answers.unity.com/questions/775784/lerping-euler-angles-make-entire-spin.html, this script helps lerp around angles that potentially pass into the negatives, which would cause objects to spin rapidly.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Properly Lerp between two angles | |
Vector3 AngleLerp(Vector3 StartAngle, Vector3 FinishAngle, float t) | |
{ | |
float xLerp = Mathf.LerpAngle(StartAngle.x, FinishAngle.x, t); | |
float yLerp = Mathf.LerpAngle(StartAngle.y, FinishAngle.y, t); | |
float zLerp = Mathf.LerpAngle(StartAngle.z, FinishAngle.z, t); | |
Vector3 Lerped = new Vector3(xLerp, yLerp, zLerp); | |
return Lerped; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment