- Home /
transform.rotate moving object away somehow,
My script is very simple:
transform.Rotate(0,5,0, Space.Self);
However, for some reason, the object not only spins, it also moves off into the direction of the axis in question, changing the position as well as the rotation. This is literally the only code in the script. Videos I've seen using the same compiler as me had shown the desired simple rotation, even though their code was identical to mine. Please help?
What kind of object are you rotating? The problem you mention can happen if the pivot point of the object is not the center of the object. This is a common problem with imported meshes.
I'm not using imported anything, just Unity's raw shape gameObjects. However, another post about another string of code that was misbehaiving provided me with a solution by creating a brand new scene.
Don't know what the problem was, but something in the scene changed the string's behaiver, which was strange since I don't recall making an changes to anything but scripting as I'm currently learning to script in Javascripting.
Thank you though for at least attempting to help. I thought Unity was broken for me for a bit as the misbahiavers were starting to build.
Your answer
![](https://koobas.hobune.stream/wayback/20220613133621im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
use world axis when using transform.rotate 0 Answers
How to rotate the camera around an object 2 Answers
transform RotateAround 1 Answer
smooth fps movements using joystick 1 Answer