- Home /
Rotation moving gameObject when position is not 0,0,0
I've spent a couple hours trying to figure out why when the gameObject is rotated it's also moving the position of the gameobject.
When the position of the gameObject is 0,0,0; the object is rotated as you'd expect and only effects the Y axis. However once the object is moved from position 0,0,0, the rotation moves the position as well as the rotation.
The gameObject is NOT parented.
Here's the snippet:
transform.rotation = Quaternion.Euler(0, ry, 0);
var position = Vector3(x, distance, z);
var worldPosition = transform.TransformDirection (position);
transform.position = Vector3.Lerp (transform.position, worldPosition, zoomSpeed * Time.deltaTime);
Answer by DESTRUKTORR · Aug 06, 2012 at 04:23 PM
Your "centerpoint" or "pivot point" is probably not where you think it is. Check each to see where the arrows/rotational-circles show up, and that is the point it will rotate about.
There is no pivot point, just it's self. it seems to make position 0,0,0 it's pivot point. Using this method; does it expect a target to pivot around?
When you try to rotate it, do the rotationary axes position themselves in the center of the object? or somewhere else? You're probably better off just opening it up in whatever 3D modeling program you used to make it and checking to see where the object's center point is located, there, as it will follow through into Unity.
They are centered; I'm using unity's cubes as place holders, no modelling applications used.
Any other ideas?
wait... what is ry? and why are you using euler angles? You may want to use traditional quaternions :P
ry was a float. Wasn't sure about using euler angles, but everything else I tried threw up errors. Sorted now thanks :)
Answer by Meltdown · Aug 06, 2012 at 07:07 PM
You need to make sure in your modelling tool that your model is saved at 0,0,0 origin and that any transforms are removed. For example Maya has a freeze transforms option.
No models, just using unity's cubes as place holders.
Any other ideas?
Your answer

Follow this Question
Related Questions
Freeze camera 1 Answer
transform.forward doesn't work in my code 3 Answers
Objects not always Spawning At Correct Location 2 Answers
how to ignore transform.position.y 3 Answers