Override the Spawning of Actors placed in the Level Editor

How would one go about overriding the spawning / loading of actors placed in a map?

What we would like to do, is tag objects with a list of GameModes they should appear in, then upon, preferably the loading of the map, choose not to load or spawn the objects if they are not available for that game mode.

In theory, I was hoping we could add AssetUserData onto the level itself that contained a lookup of actors and what game states they should be present in, then upon either loading or spawning lookup this data and suppress the creation and/or loading of the assets that are not required for the GameMode that we are in. We would probably just build some panel with radio buttons that use the GameMode alias entries to determine all the modes, and what mode they should load into.

I found a similar question, but we would like to do something slightly different to solve this problem, that also doesn’t require us to modify all of the content that has already been placed in our worlds. (Although we may have to anyway). Additionally, we are also not able to use level streaming because of the permutations of GameModes that any given asset may have to exist in at any given time.

Is there a good spot to override the loading of the dependencies in a level? How about a spot to override the spawning of the actors in the level?

Hi,

Sorry for the delay.
Usually optional loading is implemented with level streaming. Do you actually want to completely avoid loading actors that are not required in current game mode? If not, you could do filtering right after level was loaded, go through list of actors and remove entries that are not needed in current game mode. For not loading optional actors I think you will need some placeholder actors in the level that holds TAssetPtrs to an actual (BP or static mesh) assets and load them on demand with FStreamableManager.

I’m not sure if it possible at all to add Actor filtering during map loading, CCing people who might know about it.

Do you actually want to completely avoid loading actors that are not required in current game mode?

Ideally, we would love to not have to load the actors, but like you said this is where level streaming would work best.

If not, you could do filtering right after level was loaded, go through list of actors and remove entries that are not needed in current game mode.

This idea seems like the best solution at the moment, until the number of optional objects becomes a memory problem on a particular platform. I would be curious to know if and when I could hook into this process and start to run some experiments.

For not loading optional actors I think you will need some placeholder actors in the level that holds TAssetPtrs to an actual (BP or static mesh) assets and load them on demand with FStreamableManager.

This idea seems do-able as well, combined with some magic delegates to load and unload them on the fly for previewing in the editor, it could work well.

Really curious to find out more about Actor filtering Post-Load. Let me know if you find anything.

I don’t see a place in the code where you can hook actor filtering without changing engine code. Persistent level after loading goes through actor registration in UWorld::InitializeActorsForPlay so there you can add filtering. For streaming levels actor registration happens in UWorld::AddToWorld.