Lerping rotation issue

I want to lerp my players rotation. I’m trying the code below with no luck.
Depending on which direction the player is moving I will lerp the rotation ± 30 degrees

void FixedUpdate()
    {
       Quaternion roations = transform.rotation-30;
       transform.rotation = Quaternion.Lerp(transform.rotation, roations, Time.time * speed);
    }

Thanks for the help.
Josh

Your lerp is all wrong.

1 Like

I got it working correctly

degree = 30
transform.rotation = Quaternion.Slerp(transform.rotation, Quaternion.Euler(0, degree, 0), 1);

Correctly as in “does nothing?” Because your t value does not change at all. You should read the excellent article GroZZleR posted.

My player does rotate now on the y axis. I did read his article too. I update my degree variable in various places. So its not a constant 30 it changes.

if your approach is to change the angle being rotated elsewhere you might as well remove the attempt at a slerp completely.

Slerp and Lerp are purely mathematical functions which work out a midpoint between two values, if your step is 1 you are purely using the max value, not the midpoint.