How do I restart the same map with P2P multiplayer going on?

Hi All,

In my fighting game I want to do a setup that restarts the rounds in a way that is as quick as possible.
I’m doing p2p (listen server) mutiplayer.

One thing I explored was to trigger a ‘ServerTravel SameMapName’ on the authority, but this causes a hard crash (without any messages in the outlog) on the remote client.
So that does not seem to be the way to do it. :slight_smile:

What I’m looking for is something that,

  • Works during listen server play.
  • Is fast on the same current map. (Ie does not re-load the map again)
  • Clears any actor spawned since last time.
  • Resets GameState and other similar classes.
  • Re-runs 'BeginPlay’s ( I think :slight_smile: )

Are there any other engine standard ways of doing this?

Cheers

Imo this might be easy…
Lets say your characters are fighting and have 30% and 50% hp.
Then on pressed restart button:
Get game state and set rounds / wins to 0.
Set all characters hp to 100%
Set p1 to p1 position and p2 to p2 position
Give them idle animations and start countdown 3…2…1…

Restarting round like in tekken7 is imo only about this… just setting few variables to defaults and resetting characters position…

In T7 if is something broken in map, its broken in next fight round too… they do nothing more…

Or are you looking for something another?

Have you tried simply loading the same map again to see what your restart times are?

The current/old way is using a ‘Restart Game’ BP node. It takes up to around 10 seconds which is too long for me. It’s a vr game and ‘Restart Game’ is not a smooth experience for the player inside the HMD.

Yep that’s what I am trying to set up now. I have to also clear + reset a bunch of actors that are not the player characters. And reset things in the Games state like you say.
I’m just trying a cheeky ‘Destroy’ + re-spawn of the gamestate, as I’m lazy. Not sure if that will work. EDIT: Nope it didn’t. I’ll have to reset the GameState by hand.

Deleting the game state and recreating one does work but last time we used it, we had to manually trigger a fake Event Begin Play because it was not triggering on the new game state.

When you spawn a GameState it automatically becomes the new game state. But the previous one is not destroyed and remains idle, unused. What we did was GetGameState->Store the reference, CreateNewGameState, Destroy stored reference.

If you want the fastest reload time, you’ll have to manually build a system to “reset” things.

You could create a simple “Reset” Interface that you would implement on every actors / objects that need to be reset. Then you implement the reset function on each of them and tell them what they do. For instance OnReset, characters teleport to their starting location, go back to idle and restore their resources. For instance NPC’s go back to their starting locations. For instance GameState resets its variable, destroys ongoing recorded objects that need to be destroyed between reloads (like destructibles / items) and spawns new destructibles.

Maybe your interface could also implement an “Initialize” function that only triggers once in the beginning of the map just so you can implement a simple logic for each object that need to store information at the beginning of the game (like storing its starting transform).

And the correct way to sync’ multiplayer here would be to simply have every clients listen to the BeginPlay of the new GameState you spawn when resetting the game. Unfortunately as I mentioned, the last time we tried that the ‘EventBeginPlay’ was not firing on the GameState spawned. So we had to do a little “cheat”: the Server was spawning the GameState alongside a replicated actor named “WitnessGameState”. WitnessGameState BeginPlay event was triggering on every machine so every client would receive it, and it was launching the GameState fake begin play. In your case, the BeginPlay would call “Reset” on every objects in your game.