How do you handle gameplay state "mode" switching?

Let’s say your player has an objective - they get the objective - then you play a “victory” cinematic - the player might have objectives left or this might be the last objective to end the level.

End of the level means another cinematic plays, and switches to a end of level screen showing your stats. If the player still have objectives left you have to return them to the game in progress restart all the UI controls etc. to continue.

I have created the systems that are tracking the objectives, and doing all this already.

I just feel that every time I have do this work I have so many places to make sure are paused or shutdown or like a UI change or control change, and avoiding any sort of race conditions. I write it and then find the edge cases fix those then trying to get a perfect transitions for the different outcomes is a pain - maybe because I suck at coding.

  • Do you all find the same thing happens to you?

  • Do you have a master block of code that handles all the cases or do you it per objective as some have higher levels of complexity not required for simple objectives?

  • Do you wait until the gameplay is locked before you refactor this code to handle all the cases or just add as your needs expand or contract?

Probably shouldn’t be showing a victory cinematic or an end of level screen until the gamemode decides the current level is actually done and it’s time to transition to another level or back to lobby. Instead, if you want to let people compete for 2nd/3rd/Nth place just give the winner (and subsequent runner-ups) a spectator pawn until the match is done. Then you don’t have to worry about freezing everyone’s input for 5s to show some fireworks or whatever. Less work for you, and less annoying for players since they won’t have to wait for game to celebrate someone else winning when they may have really only been interested in beating the friend they queued up with.

If you’re wed to the idea of giving the winner instant gratification, at most, I’d say flash a message on the ui that Username has Won, and maybe pop up a small scoreboard so the others know how close they are to 2nd/3rd/etc.. to motivate them (or give them an excuse to ragequit lol). And maybe start a timer announcing the match will end in 30s/2m/whatver in case everyone else just mopes around instead of trying to finish objectives.

Just think of an IRL car race. When the first car crosses the finish line, they don’t make everyone stop, get out, and watch a trophy get handed to first driver before hopping back in their rides to finish that last lap.