UGameplayStatics::OpenLevel Options custom params

Can I use UGameplayStatics::OpenLevel FString Options parameter to pass any values between levels? And if so - how it should be implemented? Where can i get this string?

Thanks in advance

Hi,

I just figured this out, here is how it works:

1. UGameplayStatics::OpenLevel(this, "YourLevelName", false, "SomeVar=Value");
 2. On the GameMode derived class from the level you want to open you need to handle it like so:

 void [YourDerivedGameModeClass]::StartPlay()
 {
      FString SomeVarValue = UGameplayStatics::ParseOption(OptionsString, "SomeVar");
 }

I bet you can call this from any method defined in GameMode since “OptionsString” is set as soon as the GameMode is instantiated so you don’t really need to call this on the StartPlay().

There are many other ways to get data on the GameMode, just check the GamePlayStatics class and you will find them, there is for example: GetIntOption() that will parse an int defined on the OpenLevel.