I have a script that lets you shake a tree, and after a few shakes I want the tree’s rotation to return to normal. The issue is, I have it Lerp, it works fine if the branches are rotating counter-clockwise, but if it’s rotated clockwise, it will rotate clockwise to correct it’s rotation, it doesn’t rotate counter-clockwise.
Here’s my code,
if(!treeShaking && resetTime)
{
treeLeaves.eulerAngles = Vector3.Lerp(treeLeaves.eulerAngles, Vector3.zero, smoothSpeed * Time.deltaTime);
treeLog.eulerAngles = Vector3.Lerp(treeLog.eulerAngles, Vector3.zero, smoothSpeed * Time.deltaTime);
treeLog.position = Vector3.Lerp(treeLog.position, originalPos, smoothSpeed * Time.deltaTime);
if (treeLeaves.eulerAngles == Vector3.zero && treeLog.position == originalPos)
{
resetTime = false;
}
}
Is there any way to make it rotate counter-clockwise if the rotation is clockwise and vice versa?
Thanks in advance