- Home /
Unity Parenting weirdness in the Editor (axis gizmo not right)
Simple scenario. My script creates 2 gameobjects (named "root" and "child"). The "child" game object has a procedural mesh attached to it. Let's pretend here I am creating a cube manually that has a width/height/depth of 100.0 units and is centered in local space around (0,0,0).
rootGameObject.transform.parent = null; child.transform.position = Vector3.zero; child.transform.localPosition = Vector3.zero;
child.transform.parent = rootGameObject.transform; child.transform.localPosition = new Vector3(0,0,50.0f);
What should happen in the above example is that "root" gameobject should be coplanar to the front face of the cube. Number-wise, it is. However, the axis gizmo that shows up in the editor does not show this. It visually depicts "root" transform position to be in the center of the cube. The "child" transforms position is correct. It is also at the center.
Any ideas? Is this a bug? I'm using Unity 3.0.0f5 version if that helps.
thanks! John
Jessy is right on your problem, but just FYI: if you set transform.position internally it get's converted into localPosition. So to set position and localPosition makes no sence. You don't have to initialize the position it always have one. Just set the parent and after that the localPosition and evt. localRotation