How can I pause a game running on a dedicated server?
I'm working on developing a training simulator, and would like for the simulation to pause at various points so that the trainees can answer questions related to what they're doing.
The single-player prototype worked without a hitch, but the project I'm working on is a multiplayer game hosted on a dedicated server. So far, every attempt to pause the game has failed.
Here's the relevant blueprint code in my PlayerController:
I created "TEST_ClientRequestPause" and tied it to a button press so that I could test easier. It makes an RPC call to the server-side method (which would normally be triggered by an event on the server). The server-side event then calls other RPCs to attempt to pause the game. I've tried:
The image above shows calls to the client-only and multicast RPCs.
[2019.01.08-16.31.27:064]Strm: Error: Client request pause
[2019.01.08-16.31.27:096]Strm: Error: Invoking multicast pause
[2019.01.08-16.31.27:097]Strm: Error: Multicast pause success: false
[2019.01.08-16.31.27:097]Strm: Error: Invoking client pause
[2019.01.08-16.31.27:098]Strm: Error: Client pause success: false
[2019.01.08-16.31.27:076]Strm: Error: Server request
[2019.01.08-16.31.27:077]Strm: Error: GameMode can pause: true
[2019.01.08-16.31.27:077]Strm: Error: Invoking multicast
[2019.01.08-16.31.27:078]Strm: Error: Multicast pause success: false
The RPCs seem to be functioning as expected (the events are in the expected order and in the expected logs). The GameMode is reporting that it can pause. Perhaps network pausing is limited somewhere else (this post seems to indicate that network pausing is disabled by default). The log indicates that immediately after invoking "SetGamePaused(true)," the "IsGamePaused" node is returning false. I've also connected the boolean output of the "SetGamePaused" node to my log statement - it also returns false in all cases.
If anyone has any insight on why that might be the case, I would love to hear it. Is there an option somewhere in the project that needs to be set? Do I need to manage my RPCs differently? Answer #6 from vipeout in this post seems to suggest that the clients need to pause before the server pauses, but I can't seem to get the clients to pause (and I'm less concerned with preserving the "pauser" in the world state). Is there a known issue that would prevent a dedicated server from pausing? Are there any common mistakes that might cause the "SetGamePaused" node to return false?
If you want the game world itself to pause with the player instead of just pulling up a "pause" menu try having the level blueprint itself activate the pause node inside of itself or alternatively you can use the level bp to force every other players to press the button whenever one of them presses it
answered Feb 14 '19 at 03:54 AM
The level blueprint can look for and cast to all actors of a specific class or parent class in a level, if you link the pause event in the player class to a custom event you can call that event from the level blueprint, by using this and aplying it client side you could possibly mass pause the clients that are inside that map, however please take this suggestion with a grain of salt as I both cannot check my idea nor can I implement it since at the moment as im still wrapping my head around networking at all
You can solve it by using SetPause with c++.
answered Aug 15 '19 at 07:30 AM
Follow this question
Once you sign in you will be able to subscribe for any updates here