How to Reset / Restart a game

Hi everyone, I’ve been trying things for days, but I can’t solve my problem and I’m a little bit desperate now.

I’m making an endless runner for android, after the player dies I want the game to be reset so the player can play the game again.

Nodes that I used to achieve this goal:

Open Level: Works perfectly in the editor and when I package it for development, It stops working when I package the game for Distribution (Shipping). (Like the node is not there?) ‘Cook everything in the project content directory’ is set to true.

Execute console command: Works perfectly in the editor and when I package it for development but ofc this node will be removed when I package it for Distribution.

Restart game: Restart game needs a ‘Game Mode Object Reference’ and when I take the node ‘get game mode’ it returns a ‘Game Mode Base Object Reference’ so I can’t connect that one?

Maybe there is someone with a different idea to achieve this goal or can help me with the problem i have with ‘Open level’ and ‘Restart game’.

I really hope that someone can help me!

2 Likes

Ensure your GameMode’s parent class is GameMode not GameModeBase.

272600-ue-answerpic53a.png

Then you can cast the current game mode base successfully to GameMode and call RestartGame.

272601-ue-answerpic53b.png

7 Likes

Thx BenVlodgi, you are a hero!
Restart game is now working and it has solved my problem.

Glad that helped! :slight_smile:

Or Use “Get Current Level Name” IN the Place Of “Open Level” (Name Area) And You Can Restart Every Level Without Having To Change Nothing! Every Level Will Have Its Own Restart, AWESOME!

3 Likes

This worked for me too, thanks!

You can also create a function library with this function to use the selected gamemode when restarting:

1 Like