Download

Call event on Level Blueprint from Class Blueprints spawned at runtime

I’m looking for some advice on the best way to call an event on the Level Blueprint from Class Blueprints spawned at runtime.

As far as I figured out, the easiest way would be through the use of an event dispatcher on the Class Blueprints that I connect to an Event inside the Level Blueprint by finding all of the objects (of the class blueprint) and iterating through them. However, this seems problematic if I end up spawning dozens or even hundreds of that class blueprint (would mean I keep iterating through all of them constantly inside the Level Blueprint so I can bind the event dispatcher there).

Is there an easier way to call an event on the Level Blueprint from Class Blueprints that I have to spawn during runtime?

One question to ask is, why is this logic in the Level Blueprint? It might be better to move it into some kind of ‘manager’ actor that these spawned objects could find on spawn, cache a reference to, and notify when needed. Or you could put the logic in your GameMode BP, which is easy to get to from anywhere.

Not sure what you want to do. Do you really need to interact with them all every time some event occurs, or you need just one of them to do something?
You probably are trying to bruteforce problem that can be done without any big calculations.

Anyway best place to process such stuff is either player Pawn/character, player controller or game mode. Depends what is your event and where it logically should belong.

If you want some map generation or procedurally created content for big areas read those 2 topics:

If you want some pickup or another kind of system where player interacts only with few blueprints at once, You probably can reduce whole task to “find right bp” change single instance. But to help with this it would be nice to know what you are trying to do.

Thank you for the replies. Game Mode / Game State or just a blueprint actor in the scene makes more sense without having to touch the Level Blueprint. ./facepalm