Hi,
In my game, I’m trying to make it so that a new room spawns every time you open a door. I got that working, however, keeping track of the rooms can be annoying and can cause issues further down the line if the naming is automatic since it just calls it “Room_Prefab(Clone)” and keeps adding “(Clone)” to the name of every room after. I want to be able to name these specifically on every instantiation.
I almost got that working, however, it doesn’t work like I want it to. The way I have it working right now makes the room rename itself before it spawns another room (Which is unaffected by the name change code). I’m not exactly sure how to name the new instantiated room. Here’s my code that controls the instantiation. Any ideas?
void Update ()
{
if (door.open && !door.spawnOnce) {
// create the new room:
roomNum++;
Instantiate (Room_Prefab, transform.position, transform.rotation);
Room_Prefab.name = Room + roomNum;
door.spawnOnce = true; // make sure it's created only once
Debug.Log("New Room!");
Debug.Log(roomNum);
}