Vector3 rot = transform.localEulerAngles;
if(Input.GetKey(KeyCode.P))
{
rot.y = 160.0f;
mouseLook.enabled = false;
theCamera.localRotation = Quaternion.Slerp(theCamera.localRotation, Quaternion.Euler(rot), Time.deltaTime * 10);
}
else
{
mouseLook.enabled = true;
theCamera.localRotation = Quaternion.Slerp(theCamera.localRotation, Quaternion.identity, Time.deltaTime * 10);
}
How do I fix the camera rotation so that it will not change all the time if localRotation.y will reach to zero after I released the āPā button
It's because you're animating wrong; you're using 10 * Time.deltaTime, which is almost constant and only varies slightly each frame, instead of allowing the interpolation parameter to depend linearly on time. Use Time.time instead and set some initial startTime, then count up each frame from there.
ā CHPedersencan you give me an example on how to do it
ā jvt619