Hello, I have a problem with defining parents in Unity.
I have an empty gameobject Town with 6 Building objects inside. During the game player places 10 Citizen objects inside these buildings and they become children each of their own building.
During the game a random Citizen is picked and variable Location is defined as the Building where the picked Citizen is at the moment.
GameObject Location=Citizen.transform.parent.gameObject;
(In other words, the ierarchy is Town->Building->Citizen)
And it works almost perfectly fine, but sometimes Location is defined as Town, not as Building. What can be the problem here?