Question by
MetzgerBorgan · Aug 24, 2021 at 11:08 AM ·
z-axis
Look without Z rotation, non rigid
Hi!
I have a a free flight movement it works semi fine but the problems is I also get Z rotation when i only want the object to rotate in x and y (horizontal and vertical).
transform.Rotate(-Input.GetAxis("Mouse Y") * MouseSensitivity, Input.GetAxis("Mouse X") * MouseSensitivity, 0.0f, Space.World);
transform.Translate(transform.forward * Input.GetAxis("Vertical") * MoveSpeed, Space.World);
transform.Translate(transform.right * Input.GetAxis("Horizontal") * MoveSpeed, Space.World);
What do I need to change in order for mouse to only rotate x and y? I need it to stay non rigid.
Thanks for any help!
Comment
Found an old solution after trying all kinds of things. Wondered why even reseting Z nonstop to 0 wont help at all. this worked: float z = transform.eulerAngles.z; transform.Rotate(0, 0, -z); Thanks to Ifandbut.
Your answer
![](https://koobas.hobune.stream/wayback/20220613042110im_/https://answers.unity.com/themes/thub/images/avi.jpg)