Objects local/world cordinate question

when i put in zero zero for each of the objects, they show up in diff areas of the scene. I'm becoming confused with local and world and I"m trying to spawn something at a position but when it spawns it's off .

In the inspector, the positions is relative to they parent, unless they don't have parent. If the object don't have a parent, so, the positions are global.

In scrit you write for example:

transform.localPosition.x = 0;

With this, your object will be at same parent x axis.

Otherwise, if you write this:

tranform.position.x = 0;

Your object will be moved to the center of the scene on the x axis, but, if the parent move the x position, your object will be moved together.

A observation about rotation:

you will see somethimes something like this: you used a script to move the object local position on x axis, but the object is moving in another axis, it’s because the rotation of parent, for example, if the parent y axis are rotated 90 to any side, when moving the child object local position in x axis will move globaly in the z axis.


See my answer in your other question: