- Home /
Object Rotation doesnt work
Hello, so i have a body and according to the wasd i want to rotate front-left-right-back. Front-Back works, but left right not. And generaly i have problems with the rotation in unity...
you must be rotating Quaternion values, use EulerAngles.
Please reword the question, it doesn't really make sense. Just be a bit more detailed and post the code you're currently using, and this will be able to be answered pretty quickly by the community :D
So what exactly is working and what isn't? And what exactly do you expect each bit of code to do?
Your problem is probably related to using Quaternion components directly... these don't relate to rotations as we humans understand them. Try using Quaternion.Euler ins$$anonymous$$d:
skeleton.transform.localRotation = new Quaternion.Euler(90,0,0); // 90 degrees forward/down
skeleton.transform.localRotation = new Quaternion.Euler(-90,0,0); // 90 degrees backwards/up
skeleton.transform.localRotation = new Quaternion.Euler(0,90,0); // 90 degrees left
skeleton.transform.localRotation = new Quaternion.Euler(0,-90,0); // 90 degrees right
Also, are you trying to set an absolute rotation or add change the existing rotation? Currently you are overwriting which will ignore the current rotational state.
Quaternion.lerp and .slerp are for smoothing of angles in quaternion.
Your answer
Follow this Question
Related Questions
Why are these shapes deforming? 1 Answer
Top Down 3D moves in unexpected ways. 1 Answer
Animation problem with rotation and position. 0 Answers
Camera Limit Rotations Problem 1 Answer
Rotation Problem 1 Answer