Efficient way to despawn things

I want to create a ‘Game Manager’, that checks multiple Boolean values and changes things in the Level if certain things are fulfilled.
How should I create that in the most optimal way?
Should I use the Level Blueprint, if I do that I have to reference al lot of objects in the level.
Is that efficient enough?

Rather than checking loads of bools all the time, it might be an idea to use interfaces, or event dispatchers. If you use either, using an actor in the level makes much more sense than the level BP.

2 Likes

you’ll get better answers if you get more specific. Can you describe an example of a condition you want to watch?

actors in the level can report when something important has happened either directly to the game mode, or via interface. This way they can talk to the game mode but not tie the game mode to them.

So for instance, an enemy is killed, it sends interface message to game mode called “On Enemy Killed”. The game mode is keeping a counter and increment it by one. When the counter reaches 10, then you fire off, “Mission COmpelted” event.

So in this way, the game mode knows the rules of the game and actors in the level report about what is happening in the game. But actors are not tied to the game mode and game mode is not tied to any actors. They only reference the interface.

2 Likes

I want to change the Room layout when the Player is interacting with the door, when like 3-4 Booleans are met.

well what are the booleans

2 Likes

Whether player is facing door, has interacted with the door for the beginning and then I want to disable/enable or delete objects if the Player did react and is looking at the door

gotcha.

well, it sounds like this is all interaction between player character and a door or some actor like that.

And then you want some sort of level specific event to happen when the player has interacted with the door actor in a certain way. Right?

I think it makes sense for the door actor to hold the conditions then, and when they are all satisfied then it can send interface message to your game mode or wherever you are defining the event that happens.

In order to compartmentalize code and keep game mode from becoming too messy you can use components that attach to the game mode. Then you can GetGameMode > GetComponentsWithInterface and talk to the component via an interface.

That way your actor in the level can inform the game mode (via it’s components interface) that these conditions have been met, and then the game mode component can do whatever it wants.

This way none of the classes are hard coupled at all - they all only depend on interface.

You can also work with an event dispatcher or even just talk to your game mode directly as well if you want to keep things simpler and having a little hard coupling isn’t a big deal. BUt if you are going to have a lot of unique conditional events like this, it probably makes sense to setup some components and interfaces so that you have a “system” just for managing communications in a way that doesn’t create a dependency web.

2 Likes