Don't understand parent vs child transform in world and localspace
I have a cube (cube1) at world 0,0,0 with a scale of .05. I create another cube (cube2) which I place at world 1,0,0 also with a scale of .05. Now if I move cube2 so it becomes a child of cube1, the transform of cube2 in X becomes 19.1544. Should't it still be 1 ? I mean, it is still 1 unit away from it's parent object. What does that 19.1544 means?
To my understanding, the child takes the parents local Transform (scale, position, rotation) rather then the worlds, so the "units" are different.
If you were to reset the childs position to 0 0 0, cube2 should be exactly on the same spot as cube1, and 1 0 0 , should put cube2 essentially right beside cube1, with absolutely no space in between them, or even possibly be half way outside of cube1, because in the local space of cube1, which cube2 now inherits, 1 0 0 world space, would be the equivalent of almost 19 0 0.
I havnt really dove too deep into all of the technical behind it, and would need Unity opened infront of me (which I do not have right now), but in a simple answer, cube2 is no longer following world space, its cube1's local space.
You are right Dibbie,
I change the scale of cube1 to .01 and cube2 now is 100 units away. It does take the scale in consideration in the transform position of the children.
Answer by hexagonius · Oct 27, 2016 at 08:59 PM
The value of 19.1544 is wrong and should be 2. Since your childed cube 2 is 1 world space unit away from cube 1 but has a scale of .5, that's a distance of 2 (1 / 0.5). Something else must have gone wrong if you get that number.
Hello hexagonius,
I have redone it and I do get 20. Scale is .05 not .5
I probably moved my object a tiny, tiny bit to get 19.1544.
right, my mistake. still the same reason. since the scale is .05, and the world distance is 1, for the cube it's 1 / 0.05 = 1 / 1/20 = 20