- Home /
RotateAround a cylinder,but produced some wrong offset
i make a gameObject as parent gameObject ,called "aircraft", it has a child empty gameObject ,called "controller",the controller has a child gameObject ,called "body",the body is 3D model of the aircraft, when game start ,the parent gameObject aircraft move to forward, and i write a script control the aircraft orbit around a cylinder,and the script attach to "controller".
i use RotateAround function to control the "controller" gameObject
myTransform.RotateAround(Vector3.zero,Vector3(0,0,-Input.GetAxis("Horizontal")),rotateSpeed);
parent gameObject "aircraft" move to forward
pTransform.Translate(Vector3.forward * mySpeed * Time.deltaTime);
when game start,everything is normal,like this

but after a while, when the aircraft rotate back on the top of cylinder,some thing is wrong,aircraft not in the center of the cylinder,like this

i don't know why, need help
Answer by robertbu · Apr 19, 2013 at 05:13 PM
My guess is that the point you are using for your rotate around is not orthogonal to the position of the plane. Try changing your setup. Place an empty game object on the axis of the cylinder. Make the plane a child of the empty game object at the start position above. Move and rotate the ship by moving and rotating the empty game object (Transform.Rotate()). That way the point of rotation and the position of the ship will be aligned.
Your answer