Hey everyone, I am trying to do something that I feel should be very simple but I cannot seem to figure it out. I have a “Dungeon Generator BP class” that spawns rooms within my level. I need a way to communicate with my master room (the parent BP class for the rooms that contains exits, collision boxes, and spawn points) that “All the Dungeon Rooms are spawned, proceed with the master room blueprint to spawn other assets” seems like it shouldn’t be complicated at all but I just cannot figure it out. Currently I have it set up so the “Dungeon Generator” just spawns the assets but I want more control of it, which is why I want to delegate the asset spawning to the rooms themselves. I have attempted interfaces and event dispatchers but I am honestly too new to all of this to figure it out on my own.
It sounds actually like you have a logic problem there. You want to send a signal to the master when all the rooms have finished. But none of the rooms have this information, if the are spawning independently.
Something you could do is, for each room, report two things back to the master:
1 I have just started
2 I have finished.
The master can make a count of the number of rooms from 1, and knows it has to wait for 2 ( * number of rooms ), before proceeding.
The only timing assumption here is that one room is not very late. In that case, the master will assume everything is done, when one room is still to start.
Another option is that the master hands out ‘room tokens’. Each new room must have a room token before it can start. The master has a limited number and will wait until all tokens have been given the green light.
Thank you for the speedy reply.
Just to add more clarification to the current setup I am working with. The “Dungeon Gen BP Class” is in charge of spawning rooms (room amount integer that counts down for each room spawned successfully), checking for overlap between rooms and deleting overlapping rooms, logging and removing new/used exits respectively, Closing unused exits when the room amount integer hits 0, and currently logs the spawn points for assets and stuff that would populate the rooms.
The “Master Room BP Class” so far has operated without any code. It contains the overlap boxes, spawn points, and exits that the generator spawns (Spawn actor from class). The master room is not one of the rooms spawned, there is a “Dungeon Spawn room” that the generator spawns first and then spawns rooms from “Dungeon” or “Cave Room” Classes. The Master Room pretty much defines what each room in these classes can contain (exits, spawn points, collision, mesh) Everything is currently done through the Dungeon Generator.
My main concern is I don’t want the asset spawns to be entirely random, just random to a certain degree (Random within defined outlines (Barracks, Library, Kitchen, Roots/Natural) But as I am typing this I am realizing I could have all this happen after the overlap check and before the generator goes on to spawn the next room. Part of me just feels it would be a lot cleaner if I had that functionality coded to the rooms.
I can attach some screengrabs of my blueprints if you want to take a look and give me any other tips on how I should go about this.
To be fair, you did say
which is why my answer was about that
Having the rooms decide what to do is much more elegant, but you do still need a central control of some sort, but only in a delegation sense. So, tokens for each type of room, for instance.
The room BP can still be very general, and just pickup hint/guide info from the controller.
Do everything from the controller is a 1960s programming nightmare :D, getting the room BP to do all the work is a much better idea.