Flip 3D Character Rotation 180 on Y axis
I'm making a 3D game that works like a 2D game where you click the left arrow and he goes left, and you click the right arrow and he goes right. So when he goes left I'm trying to flip his Y rotation 180 degrees. I can't make any sense of what's wrong, this is my code
z = Input.GetAxisRaw("Horizontal") * Time.deltaTime * speed; transform.Translate(0, 0, z); if (z != 0) { if(z < 0) { isRight = false; } if(z > 0) { isRight = true; } if (isRight == true) { transform.rotation = Quaternion.Euler(0, 180, 0); } if (isRight == false) { transform.rotation = Quaternion.identity; }
Use Quaternion.Euler(0,0,0) ins$$anonymous$$d of Quaternion.identity
Answer by SupaJakeHD · Jul 30, 2018 at 04:58 AM
I eventually figured it out for anyone wondering, I had to rotate in space.world, and also translate in space.world
Your answer
Follow this Question
Related Questions
How to rotate a camera slowly along a tween? 1 Answer
Weird rotation when using Slerp!!? 3 Answers
Auto level an object 0 Answers
How can I set rotation properly? 0 Answers
Problems With .rotate behavior 1 Answer