- Home /
Question by
Dracolyte · Apr 07, 2021 at 07:43 PM ·
rotationquaternionlerp
My Quaternion.Lerp() doesn't do anything
Im kinda new to unity and its probably a noob question but I have a problem. My rotation script works nearly perfect except that the quaternion cant be lerped. In my script the prevRot is the local default rotation that the player has. GetMoveDistance() is the calculated user input to move the player on the x axis. The rotation depends on GetMoveDistance(), so the rotation changes to left or right if i swipe on the screen. But the rotation of the player doesn't go instantly (by instantly i mean like 1 second) back to its original rotation, that i want to archieve with Quaternion.Lerp(). Any ideas why it doesn't do this?
The problematic piece of my script:
Quaternion GetQuaternion()
{
Quaternion rot;
Quaternion preRot;
float angle = Mathf.Atan(GetMoveDistance()) * Mathf.Rad2Deg / 2;
preRot = Quaternion.Euler(0, -angle, 0);
rot = Quaternion.Lerp(preRot, prevRot, Time.deltaTime * rotSmooth);
return rot;
}
Comment