- Home /
Question by
abhisheyk · Nov 29, 2016 at 08:15 AM ·
rotationquaternionslerp
Quaternion.slerp is not completing the rotation
Hi, I have a submarine object with a Y coordinate at -13.4. that is the water level. When the submarine's Y value is greater than -13.4 I want to rotate it so that the X degree is 0. I am using the following code to do so in the Update() function
if (transform.position.y > -13.4f)
{
subRotation(0, 1f);
}
and the subRotation function is as follows.
public void subRotation(float depthRotation, float yreturnspeed)
{
Vector3 wantedRotation = new Vector3(depthRotation, transform.rotation.eulerAngles.y,transform.rotation.eulerAngles.z);
transform.rotation = Quaternion.Slerp(transform.rotation, Quaternion.Euler(wantedRotation), Time.deltaTime * yreturnspeed);
}
But this function rotates it only till 2.71 degree. Can someone tell me what am I doing wrong?
Comment
Your answer
Follow this Question
Related Questions
Quaternion Slerp help 1 Answer
Choppy rotation of character around y-axis 1 Answer
Get slerp to work just as LookAt(,Vector3.right) does 1 Answer
Quaternion.Slerp on local axis 1 Answer