Hi guys, I want to rotate an object but only across the x and y axis. Also the object shouldnt be able to flip. I am guessing that I have to lock the z axis somehow. I found this online:
transform.Rotate(Input.GetAxis("Vertical") * speed.x,0,0);
transform.Rotate(0,Input.GetAxis("Horizontal") * speed.y,0);
But it doesn’t work. How could I fix this?
That should work fine so you are doing something somewhere else. First check it is definitly the Z axis you want to lock (it might just look like the zAxis from a given cameras perspective)
Secod make sure there are no rigidbodies on the object and if there are set them to isKinematic (to test if its your issue)
As for not flipping you will have to write some logic to cap your rotation to a given value. E.G if rotation.x > 90 then rotation.x = 90