Confusion about parenting

Seems I don’t understand how parenting works.

I have 6 prefabs which have been placed within an Empty Object in the Inspector. When I move this empty object, the 6 prefabs move as well.

However when I access my prefab’s localPosition (prefab.transform.localPosition), this returns their world position. And when I access the prefab’s parent (trigger.transform.parent), I get null.

I had expected trigger.transform.parent to return a reference to my prefabs’ parent Empty Object and the local position to be relative to the Empty Object that contains it in the Inspector.

Am I missing something?

That’s the behavior you would get for an object that has no parent, so I wonder if you’re referencing the prefab itself (which has no parent), or the instance in the scene (which does).

–Eric

Thanks for the help, Eric5h5. I was referencing the instances and not the prefab, but as you may guess, there was a bug on my part in my message passing (using Blurst’s Message Architecture - http://technology.blurst.com/unityscript-messaging-system).

In short, I ended up calling ‘gameobject.gameobject.transform’ which gave invalid results as you can expect.

I removed the extra "gameobject’ reference and all’s well.