Is there a way to activate a child of an instantiated prefab only?
Hi. I have a prefab room that has three exits on it that are deactivated in the inspector.
I want to spawn this room prefab, check if it collides with anything, if it does, delete it. If not, then I want to enable the exit child objects so they can create other rooms off this room. My problem is that when I activate the child exits in the first instantiated room, it turns on the exits in the 'main' prefab (the one I built in the inspector) then when the other rooms are spawned from this prefab, the exits are already activated because I turned them on when I spawn the first room.
Is there a way to activate child objects of an instantiated object ONLY and not the main prefab so no other spawned room prefabs have their exits children already activated?
Here's what I'm using to activate the children atm (I know I can cut this down, I've done it like this for now, for testing)
GameObject newRoom = Instantiate(room, transform.position, Quaternion.Euler(0f, 0f, 0f));
newRoom.name = "Start Room";
Transform southExit = newRoom.transform.Find("exitPointSouth");
Transform eastExit = newRoom.transform.Find("exitPointEast");
Transform westExit = newRoom.transform.Find("exitPointWest");
southExit.gameObject.SetActive(true);
eastExit.gameObject.SetActive(true);
westExit.gameObject.SetActive(true);
}
Your answer
Follow this Question
Related Questions
Unet Spawn Prefabs When Scenes Changes 0 Answers
Problem spawning prefabs client side, stand alone build. 0 Answers
New input system and prefab position problem 1 Answer
Characters not attaching to prefab location when spawned? 0 Answers
How to make a prefab spawn on the same spot on a rotating object? 1 Answer