- Home /
Problem is not reproducible or outdated
Object rotation broken
When I try rotating the pages of a simple placeholder book I made in Maya that I brought into Unity, the rotation changes sporadically.
Each page of the book at a local rotation of 0,0,0 are on the right hand side of the book. In Maya I made it so that at 180,0,0 the pages would be on the left hand side of the book.
Pretty simple right? When I manually rotate each page in the scene, the second the X value goes slightly past 90 degrees, the Y and Z values both change from 0 to 180, so now instead of (90,0,0), the pages are (90,180,180) and technically at (0,180,180) the pages will be on the left-hand side of the book. This would be OK if the object didn't start freaking out when I try lerping all of the values through code.
I believe the issue has to do with my Pivot points in Maya but I'm not quite sure. I made sure to Freeze Transformations on all of the pages. Did I miss a step? Thank-you!
What about to insert your page into empty object, and then rotate this empty object?
Are you rotating it with the widgets in the editor or with some script? It kinda sounds like a gimbal lock issue.
I give up, i remade the object and created empty gameobjects for each page to rotate around
What method were you using to rotate the object? You can get the behavior you describe if you use euler angles to apply rotation changes. If you use quaternion rotation it gets rid of the issue.
So when rotating, don't do this:
transform.rotation.eulerAngles = new Vector3(90, 0, 0);
Ins$$anonymous$$d, do this:
transform.rotation = Quaterion.identity * Quaternion.Euler(90, 0, 0);
There are other quaternion based rotation methods on the Transform and Quaterion objects that may be useful for what you are doing. Basically, stick with quaterions whenever manually animating a rotation.
I can't remember but I believe I tried that and others. When I remade it everything worked. So it probably was the pivot points.
Follow this Question
Related Questions
Instantiated Game Object is at the wrong location. 1 Answer
How do I rotate the hook? 1 Answer
Use a single rotation axis of a freely rotating object 1 Answer
Dropping an object behind player in respect to rotation,How to drop an object behind the player 1 Answer
transform.position on basis of rotation 0 Answers