How to implement "restart" function

[link text][1]

I am working on a local two players game like what the video shows. I want to implement the function to restart the game once any of the two players win the match. The following images show what I currently did with blueprint. It didn’t quite work as what I expected. Like the last image shows, the two players didn’t spawn properly. Did I use "restart game " in a wrong way? Or is it because my game is a two players game? Basically all I want is to put everything back just like the game just starts. Do I have to manually reset all objects position to its original ones in order to implement “restart”? Thanks.

228084-capture3.png

Well, you can destroy this two players, spawn two new ones and possess them by their player controllers. Or “reset” them manually, which means reset their score, health, teleport them to some start locations and so on…

Hey there, is there a problem using Restart Game function from the game mode, so it reloads everything again?

Currently my second blue print is in widget’s blue print where I display that two buttons. Do you mean I should put them in game mode’s blue print? If yes, how can I do that? Also, Currently with Restart Game, what I will get is what the last picture shows, it seems like players didn’t spawn properly, you can see nothing from the camera, although everything is fine when the level was loaded for the first time.

That’s also what I am thinking if I can figure out a better way to do this. But do you know whether there is any way to use Reset Level or Restart Game provided by Unreal?

Are your values inside GameMode? because RestartLevel I believe will only reset values [variables?] in GameMode bp… Just make a test, create a var with value 0 in gamemode, when game starts set it to 1, and when a player wins, after the reset level, try printing the variable and see if its 0.

One thing I just realized is that I can’t link “get game mode” to “restart game”. It seems like that “get game mode” returns “game mode base” that is not the same as “game mode”. I watch tutorials online, people can simply link those two things together. So I guess Unreal was changed over the time.

One thing I just realized is that I can’t link “get game mode” to “restart game”. It seems like that “get game mode” returns “game mode base” that is not the same as “game mode”. I watch tutorials online, people can simply link those two things together. So I guess Unreal was changed over the time.

What i was saying is to just call Restart Game to restart the entire level from scratch.

You need to cast it.

It seems like cast will always fail in run time. I print text after “restart game”, text is never printed. Instead if I link “print text” to “Cast Failed”, text will be printed.

What is the game mode you are using? You can check that on the project settings.

I start my project with Unreal’s default advanced vehicle one, so my game mode is also the default one, what I need to do next?

Go to the project settings and pick Maps & modes and you should be able to see the game mode picked. Send a screenshot of that screen.

Can you see my post?

Instead casting to GameMode try casting to VehicleAdvGameMode and see if you can access Restart Game. If that doesn’t happen just create a Execute Console Command node with the RestartLevel command. Another alternative is getting the player controller and running the RestartLevel function.

VehicleAdvGameMode is considered as game mode base instead of game mode, so I can’t link it to restart game. I used ResetLevel above, so last picture shows that it didn’t work properly. The two players are not generated.

Yeah, Game Mode Base was introduced a few versions ago.

You tried the console command RestartLevel?