Getting starting offset of embedded objects in prefab

Hi all,
I have a certain prefab that holds inside some boxes, so I try to save their initial offset to move them back when needed, I know its apparently simple thing just do in each box:

originaloffset=transform.position-playerShip.transform.position;
(prefab is the playerShip)

And when needed add the offset to the player position but for some reason the initial offset of each box seems to have same value which obviously is wrong. I tried saving the offset at Start and Awake with same results, what am I doing wrong here? thanks in advance for any help =)

You can just use transform.localPosition. This is in relation to the parent object.

1 Like

Thanks it will be handy to know its possible to have local position too, I thought we only get access to global as the transform position always returned the global. However I get same issue, all boxes have the original local position to same value which is not possible, I mean Im totally sure the boxes are not in same spot in the prefab, and when the prefab is loaded then they are repositioned but since the position is grabbed on awake or start it should work, right? then am I missing something?

Edit After some not very clean attempts I managed to get through it saving the position of each box in the main prefab Awake function, aparently the boxes were repositioned before their own start/awake was called so the position saved is where I put them on the prefab Awake function, so calling a save position function from the prefab Awake fixed it, thanks for the help =)