- Home /
Rotating doesn't work correctly?
So i'm rotating a cylinder about the z axis with the following code:
var zRotation = 1.0; InvokeRepeating("repeatFunc", 0.1, 0.1);
function Update () {
}
function repeatFunc () { zRotation = zRotation + 10; transform.eulerAngles = Vector3(0, 0, zRotation); }
Whats weird is the rotation is skewed. It doesn't rotate around the centre of the cylinder but instead a point quite far off so it looks weird and mucks up my collision detection. Does anyone have any idea why this is happening and how to fix it?
Thanks!
Answer by fherbst · Jun 18, 2010 at 05:24 PM
One simple workaround for wrong pivots is to create an empty GameObject where your pivot should be (and oriented like your pivot should be) and then parenting your object (in your case the cylinder) to it. Now you're able to correctly rotate the newly created GameObject (and thus your object parented to it) without any skewing or other strange problems.
Answer by e-bonneville · Jun 18, 2010 at 04:51 PM
Give this script a shot:
var speed = 3;
function Update () { transform.Rotate(0,speed,0); }
It should do the trick for you. Good luck!
Ah sorry that rotates round the y axis and even that is still lopsided :(. Thanks anyway!
It sounds like your pivot is whacky on the model (or you have a strange transform hierachy)
Your answer
![](https://koobas.hobune.stream/wayback/20220613062426im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Object generator? 1 Answer
Unity iPhone/iPad autorotation 2 Answers
Can I use unity 3d as a component of UI in ipad app? 0 Answers
How to call a routine every 3 seconds? 2 Answers
A node in a childnode? 1 Answer