- Home /
Neutralising child rotations -> Parent
I need to transfer the rotations of a child gameobject to the parent gameobject. In theory this should result in the same orientation/position for the child object?
The problem is that that when i perform the swap (transfer of rotations) the game object appears to move slightly. What is the best way to transfer rotations from child to parent. neutralising the child rotations?
e.g.
Quaternion qVals = new Quaternion(childGameObject.transform.rotation.x,
childGameObject.transform.rotation.y,
childGameObject.transform.rotation.z,
childGameObject.transform.rotation.w);
childGameObject.transform.rotation = Quaternion.identity;
parentGameObject.transform.rotation = qVals;
Do you mean that your child moves when you rotate the parent? That is expected to happen, if it is off center and you should reset the position after your rotation.
Answer by sparkzbarca · Dec 22, 2012 at 11:10 PM
Like the ojbect is not rotating in space but the objects center is moving?
Thats impossible.
X Y Z define the axis around which to rotate
W defines how much to rotate.
also
qVals = childgameobject.transform.rotation; way quicker that that whole copy each bit there.
Child itself should rotate after you rotate parent
if you want to void that out
parent = child child = new
This is the problem wtih your method
child = new parent = old child rotation NOW the result of that is child rotation is related to parent.
When parent chagnes it chagnes child. rotation as well as position correct?