Download

Command line argument for starting level does not work for shipping version?

UE version 4.21

We need our game to start on different levels for different users.

Thus, we specify, for example, the “OCU” starting level for our game at runtime with a command line parameter for our packaged game like this: OurGame-Win64.exe OCU

That works fine with a debug packaging, but it does not work for a shipping packaging (the shipping version just opens the default level). Does the shipping packaging handle command line parameters differently? Any suggestions?

Thanks

If you set define UE_ALLOW_MAP_OVERRIDE_IN_SHIPPING as 1 via UE4’s build system, it should work.

See UGameInstance::StartGameInstance():


 const TCHAR* Tmp = FCommandLine::Get();

#if UE_BUILD_SHIPPING && !UE_SERVER && !UE_ALLOW_MAP_OVERRIDE_IN_SHIPPING && !ENABLE_PGO_PROFILE
// In shipping don't allow a map override unless on server, or running PGO profiling
Tmp = TEXT("");
#endif // UE_BUILD_SHIPPING && !UE_SERVER && !UE_ALLOW_MAP_OVERRIDE_IN_SHIPPING && !ENABLE_PGO_PROFILE

#if !UE_SERVER

Or just override the entire function if you have some extra special code.
e.g. map list, custom invite solution