How to force game mode during level loading?

I have a level, that overrides a game mode to “Drive Mode” - that is ok.
But in some cases I would like to run same level with different “Test Mode” game mode - how to do this?

I am trying this way:

	FString GameModeClassName = TEXT("/Game/Game/BP_TestMode.BP_TestMode");
	FString Options = FString::Printf(TEXT("game=%s"), *GameModeClassName);
	UGameplayStatics::OpenLevel(this, FName(*head.mapName), true, Options);

Level loads ok, but still in default “Drive Mode” instead of my “Test Mode” with this log output:

LogStreaming: Display: FlushAsyncLoading(899): 1 QueuedPackages, 0 AsyncPackages
LogUObjectGlobals: Warning: Failed to find object 'Class /Game/Game/BP_ReplayMode.BP_ReplayMode'
LogLoad: Warning: Failed to load game mode '/Game/Game/BP_ReplayMode.BP_ReplayMode' specified by URL options.
LogLoad: Game class is 'BP_DriveMode_C'

GameModeClassName path seems to be ok (that double /Game/Game is ok) - because when tried to open from wrong path I got additional error:

LogStreaming: Warning: LoadPackage: SkipPackage: /Game/Game/aaaaaBP_TestMode (0xD86C1790531A7C0E) - The package to load does not exist on disk or in the loader

BP_TestMode is Blueprint Class derived from GameModeBase

When I tried to use just path “/Game/Game/BP_TestMode” I got an error:

LogUObjectGlobals: Warning: Failed to find object 'Class None./Game/Game/BP_TestMode'

I did some debugging inside UE5 internals and found correct way:

FString GameModeClassName = TEXT("/Game/Game/BP_TestMode.BP_TestMode_C");

So I’ll left this topic as someone else may have similar problem.

Anyway - could someone explain me why I need to do this that way?
What that path really mean?
I guess that part prior to ‘.’ is file path in game asstes, but what really is “BP_TestMode_C”, what mean “_C”, why it is “C” etc.?
Internally it is referred as “class name” in UE5 source.

When I point RMB this BP_TestMode asset in Content Drawer I have an option “Copy Object Path” that seems to intended to copy to clipboard that what I need, but instead of that it copies “/Game/Game/BP_TestMode.BP_TestMode” in my case, so without this “_C”.
Is this bug in editor, or there is an anther explanation?

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.