- Home /
Different child position when parent gameobject selected
Hi all, I'm having an issue with the position of a game object child of another. This is the object hierarchy:
I'm dynamically instantiating the "hero" object and then parenting to him the "sphere" objects. After this I move the main "hero(clone)" object containing all its children in the scene.
Everything is good until I have to delete everything, save and then re-instantiate the entire object. The process require me to instantiate the "hero" object again, move it again in the position I previously saved and then put on it my spheres (all this programmatically). It looks good at a first impression but when select the "hero(clone)" object the position of its children change:
(the left part rapresents the unselected "hero(clone)" while the right part the selected.
After I instantiate the "hero" prefab in the scene (becoming "hero(clone)") I set its position and rotation to the saved values and same thing when I recreate the spheres (i save each sphere coordinates). So if the character is not selected everything seems working but when i select it all is children except for the spheres moves to the position where it was originally spawned the first time.
I think it may happen because of something I do during my initialization procedures, but I can't get how is it possible that the same object can store 2 different position coordinates at the same time.
I'm not looking for a solution to my bug in the code (because there is one somewhere, i'm sure) but I'd love to read some ideas about how this can be happening. I tried everything that came in my mind and I have very few alternatives left. So thanks to anyone can imagine a reason why this is happening!
I believe I might have had a similar problem here: http://answers.unity3d.com/questions/359688/how-do-i-get-the-global-position.html
similar indeed, but not the same because I have a direct reference with my instances, I don't find them in the scene. Thanks anyway :)
Your answer
Follow this Question
Related Questions
Instantiate a GameObject at a position specific to an element that was found in a text 1 Answer
Is gameObject present at coordinates (x,y,z)? 1 Answer
Adjacent Placement of Objects according to varying height 0 Answers
Creating instance of GameObject(Holding component) at same location as object that holds the script 1 Answer
Keep instantiated GameObject's position while parenting it to another GameObject 3 Answers