Hey,
I want to rotate my Camera slowly 2 seconds after the script starts but my camera always rotates instantly to the new angles. Can anyone please help me with this? I tried a lot but nothing seems to work
Here’s my code:
private void Update()
{
if (cam.transform.rotation.z != 0 && cam.transform.rotation.y != 45 && camMovement == null)
{
camMovement = StartCoroutine(MoveCamera());
}
}
private IEnumerator MoveCamera()
{
yield return new WaitForSeconds(2);
cam.transform.rotation = Quaternion.Slerp(cam.transform.rotation, Quaternion.Euler(0, 45, 0), 1f * Time.deltaTime);
cam.transform.rotation = Quaternion.Euler(0, 45, 0);
StopCoroutine(camMovement);
yield return null;
}