Question by
LeadAirBalloonGames · Feb 13, 2019 at 04:04 AM ·
c#rotation axis
Fastest way to set z axis rotation to 0 C#
In the script I'm making I need to set the rotation of the z axis to 0 while preserving the rotations of the other axis when I press space. What is the simplest way to do that?
Comment
Best Answer
Answer by xxmariofer · Feb 13, 2019 at 08:59 AM
not tested but should work
Vector3 eulerRotation = transform.rotation.eulerAngles;
transform.rotation = Quaternion.Euler(eulerRotation.x, eulerRotation.y, 0);
Your answer
![](https://koobas.hobune.stream/wayback/20220612191628im_/https://answers.unity.com/themes/thub/images/avi.jpg)