I have an empty which is parented to a camera.
I’ve used variations of the following code to tell the camera to rotate 90 degrees around the empty on a keypress:
if (Input.GetKeyDown (KeyCode.RightArrow))
transform.Rotate (transform.rotation.x,transform.rotation.y+rotationIncrement,transform.rotation.z * rotationSpeed * Time.deltaTime);
I’ve set the rotationIncrement variable to integer and float values of 90 and 90.0f, yet still see results like 89.2, 91.3, etc. adding up on each rotation.
I’ve also done it with rotationSpeed and deltaTime left out but it doesn’t change the result.
Is there a way to avoid the imprecision? Or do I just need to do a < or > check and clamp the result of each rotation?