- Home /
How can i turn this into a Lerp rotation?
Ive looked through the documentation for Unity and i have tried many different solutions for my problem but i cannot seem to get this rotation to be a Lerp? Does anyone have a working solution to this?
handHold.transform.rotation = Quaternion.Euler(new Vector3(0, 0, angle * -1 - 180));
Any help will be much appreciated :)
Answer by robertbu · Jul 24, 2014 at 04:43 PM
Declare a class variable of type Quaternion at the top of the file. With the 'new', I'm assuming you are writing in C#, so do:
public float speed = 4.0f;
private Quaternion qTo;
Then in Update(), you do:
qTo = Quaternion.Euler(new Vector3(0,0, angle * -1 - 180));
handHold.transform.rotation = Quaternion.Slerp(transform.rotation, qTo, Time.deltaTime * speed);
This will be an eased movement. For a non-eased movement, replace 'Slerp' with 'RotateTowards' and adjust 'speed'.
Your answer
Follow this Question
Related Questions
Lerp Rotation in World Space 1 Answer
Slerp / lerp not creating a smooth transition 2 Answers
Smoothing the characters rotation with Lerp 2 Answers
How to ROTATE an object without slowing the ends (lerp) 3 Answers
How would I smooth out a Quaternion? 2 Answers