- Home /
"If" Statement
I used this code to make that if the rotation is less than 45 then rotation in Z axis is equal to 0 but doesnt matter if it is less than 45, if i Input.GetKeyUp(“a”) it allways run the code so i dont want that, please if you can improve my code, im newbie. Help, Thanks.
if (transform.rotation.z <= 45) {
if (Input.GetKeyUp (“a”)) {
transform.eulerAngles = new Vector3 (0, 0, 0); }
}
Answer by tanoshimi · May 29, 2016 at 07:15 AM
transform.rotation is a quaternion. So quaternary.rotation.z does not represent degrees of rotation in the z axis. You probably want transform.rotation.eulerAngles.z
Your answer
![](https://koobas.hobune.stream/wayback/20220612081827im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Rotation along 8 points following mouse. 1 Answer
Different Explosion for Different Collisions 3 Answers
Problem with Counting Collisions 2 Answers
contacts.normal question 1 Answer