Load submap with game mode


I’m trying to have a set of actors load when I’m in a particular game mode. It’s working, but I don’t have a way of detecting when it failed.

Here’s what I have so far:


And inside my PlantTheBomb::InitGameState

	UWorld* TheWorld = GetWorld();

	FString CurrentLevel = TheWorld->GetMapName();
	// Assume the plant the bomb sub map is named "currentMap_PTB"
	CurrentLevel += "_PTB";

	FLatentActionInfo LatentActionInfo;
	LatentActionInfo.CallbackTarget = this;
	LatentActionInfo.UUID = 1;
	LatentActionInfo.Linkage = 0;

	// TODO: Find a way to get a completion callback with a success/fail indication
	// and bonus points if I don't have to use a BP callable function...
	LatentActionInfo.ExecutionFunction = FName(TEXT("OnStreamingPTBLevelComplete"));

	UGameplayStatics::LoadStreamLevel(GetWorld(), *CurrentLevel, true, true, LatentActionInfo);

Is there a way to have some C++ callback with some indication of success/failure so I can report that back to the level designer if something isn’t setup right? Would be massively more helpful to them than having it silently fail (or having to read the output log for spelling mistakes like

LogLevel: Warning: Failed to find
streaming level object associated with

and interpret what that means.

Thanks for any suggestions!

Not posting this as a solution since it isn’t really one, but I’ve decided not to load the submaps from code.

Instead I have something like: DesertMapSm_PTB (game mode specific map) And it has sub-maps for the level geometry, team-play game actors, etc.

It’s just a change of mindset. Instead of having one map that supports a bunch of game modes and loads the right bits, I have a specific map for that area plus game mode. Other maps for the same area and a different game mode will just load the same aesthetic sub-maps.