So a few weeks ago I asked how to implement round based match and was told game instance would work, and that works great as long as no player leaves or joins the match late.
So lets say I have 3 rounds (in game instance), that get incremented after every match end (Under game mode), but then someone joined late. The person who last joined would have CurrentRounds = 0, and would lead to some weird things happening.
How do I go about doing this under something like a session instance that is managed by the server?
The way I currently have it is that at the end of the round the GM resets (
RestartGame() - This resets the data as well). Otherwise I would need to get all the actors in the map and reset them to the way they were at the beginning of the match. I tried using game state before but it causes a lot of issues with the match state and the actor locations (Deleting previous spells that exist on the map, move all players back to spawn, start timers, and many more issues that lead me to resetting the GM as the quickest implementation).
Game Instance is for persisting data between level transfers. For round based management you should use GameState which has all the various game states already defined and you can define custom states, then from the game mode you can set the various states in your game and handle players leaving and joining, including mid match.
Restarting the match (RestartGame()) is restarting the GM, which resets all current data. Otherwise I would have to create a reset on all the game objects and reset them to the way they were at the beginning of the match. I have had trouble with this for the longest time. Even the shooter example resets the GM once the round ends (Via RestartGame()).
Sadly after more research and testing the only method to fix this is by implementing a
ResetInterface once the round timer is up which does the following:
Player & PC:
GameStates & PlayerStates:
-Reset score and Death counts
-Hide mesh/particles, and disable collision
Enable visibility and collision
and under GameMode::RestartRound ill call something like:
for (FActorIterator It(GetWorld()); It; ++It)
Feels like a pointless post, was trying to work with a broken design (Should of just re-made it) ; just hope it helps someone out.