x


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

more ▼

asked Jan 25 '11 at 05:46 PM

John 25 gravatar image

John 25
3 1 1 4

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

Jan 25 '11 at 07:24 PM Bunny83
(comments are locked)
10|3000 characters needed characters left

1 answer: sort voted first
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x1662
x660
x321
x69
x23

asked: Jan 25 '11 at 05:46 PM

Seen: 1392 times

Last Updated: Jan 25 '11 at 05:46 PM