- Home /
Transform.eulerAngles only x and z
Hi, I have to rotate a Gameobject only to the x and z to 0.00f and 0.00f, but I'd like that the x angle will be the same that in the previous frame. (so no in this way)
GameObject.Find ("player").transform.rotation = Quaternion.AngleAxis (0.0f,Vector3.right);
GameObject.Find ("player").transform.rotation = Quaternion.AngleAxis (0.0f,Vector3.forward);
thanks
Answer by romatallinn · Jan 05, 2017 at 07:04 AM
This solution should work:
Transform playerTransform = GameObject.Find ("player").transform;
playerTransform.rotation = Quaternion.Euler(0, playerTransform.rotation.eulerAngles.y, 0);
Don't forget to click the "accept answer" button.
Answer by tanoshimi · Jan 05, 2017 at 07:08 AM
Vector3 currentRotation = playerTransform.rotation.eulerAngles;
playerTransform.rotation.eulerAngles = new Vector3(0, currentRotation.y, 0);
Your answer
Follow this Question
Related Questions
Transform.RotateAround Issues 1 Answer
How to add limit to object rotation? 1 Answer
Rotation around z-axis always local space and not world? Vector-axis angle projection calcuations. 0 Answers
Issues with copying Y axisrotation of another object 2 Answers
Transform.Rotate() is rotating less than given rotation. What's going on? 4 Answers