- Home /
Updating localPosition(?) in a scaled transform parent
It seems that I cannot update by script localPosition or position after I have parented a gameobject to another scaled gameobject at runtime.
The position coordinate shows up as the same in the inspector even after applying several different position and localPosition changes by script.
How do you update the localPosition by script of a gameobject that is a child of a parent gameobject?
Is that because you are not multiplying through the scaling so it's very very small or did you discount that already? Transform.Translate should attempt to move the object relative to the world scale not to the scaled coordinates.
Answer by Bunny83 · May 14, 2012 at 10:49 AM
The localPosition is relative to the parents coordinate space. If you scale your parent for example to 0.01 on each axis, the local coordinate space is shrinked by a factor of 100.
That means, assuming that the parent is at position 0,0,0 in worldspace, a childobject at 200,0,0(local space) will be at 2,0,0(world space).
Your question isn't really clear what actually happens. Do you mean that even when you assign a new position (no matter if local or global) the position doesn't change? In this case you propably have either:
a scale of 0.0
another script or code fragment that continously resetting the position
or an Animation attached that animates the position to be at a specific position.
Your answer
Follow this Question
Related Questions
How to change game object's parent in hierarchy without changing it's transform's position? 1 Answer
Accessing children of instances vs children of original prefab 1 Answer
GameObject position and localPosition not changing in hiearchy, only in script. 0 Answers
Transform child object over time and then destroy it. 1 Answer