I have an object that rotates when “Q” pr “E” pressed, i use that object to rotate camera around player
if (rotationQueued == false && camRotDirection != 0)
{
camRotAmount = new Vector3(0, 90 * camRotDirection, 0);
lastCamRotation = cam.rotation;
rotationQueued = true;
targetCameraAngle = lastCamRotation.eulerAngles + camRotAmount;
}
cam.eulerAngles = Vector3.Slerp(cam.eulerAngles, targetCameraAngle, 10f * Time.deltaTime);
if (cam.eulerAngles == targetCameraAngle)
rotationQueued = false;
it works totally fine when targetCameraAngle is 0, 90 or 180, but when it becomes 270 (or -90) degrees rotated object starts to spin uncontrollably
on GIF ('m pressing “E” to rotate object/camera by -90 degree ox axis Y
Why is that happens and how can i fix this?
Thanks