Reinstantiate Game Mode

Greetings !

I just figured out that, OpenLevel() or ServerTravel() will not recreate the game mode actor or even reset it, So I tried to use UEngine::LoadMap() which sets game mode to NULL for some reason.

Is there any way I can manually reinstantiate the game mode?

There currently way to change the game mode during play as stated here

But it does not mean you can’t think out of the box :stuck_out_tongue: technically you can make single game mode which function platform for other game modes (in diffrent class not related to GameMode), kind of like plug-ins that can be switch between. You know some multiplayer games have “objective” mode, think how to fit that in single game mode and that might bring you to proper solutions. Considering you using C++ it should be a lot easier to for you.

Thanks for your response, ,

Would I be able to call that “out of the box game mode” from blueprints? (since my blueprints call the c++ game mode I created.

Just use the “restartlevel” console command

Didn’t work for me, since it did not reset the Game mode properties to their defaults :confused:

Are you sure? The point of that console command is to do exactly that

yes I did that, and it crashed unreal because my “Wizard” actor receives “out of index” color integer, also Game Mode beginplay is not recalled.

So, Any news about this?

I just looked at the code to verify my assumptions. RestartLevel is the same thing as "open ", which means it spawns a new game mode

Oh I edited my last comment, but it seems that it didnt save…My bad.

I have figured out what you just said earlier before you post this, and figured out why the crash occurs after restarting the game.

If you can help me in this I’d be very glad :

So My game uses 2 characters, one character per player, I use the defaultly spawned character for player0 and i spawn another character (with a controller) for player1 to use. When I restart the game, I get an additional player spawned (having 3 players), I dont know why this happens :confused:

I even tried to destroy all actors before restarting, but didnt work, I still get 3 characters.

Ill dig more into this and see, Anyway Thanks for your help :smiley:

EDIT:

Okay I figured it out, when I create a player controller using UGameplayStatistics::CreatePlayer(), the player persists when restarting level, so I had to add an additional check whether i already have player1 or should i create one.