Hello
First: I’m working on a Multiplayer Battleground Shooter Game Like other games like (Fortnite, etc.)
I need to know what is best to work with (Game Mode or Game State)considering the following questions and also I need some answers to them:
1- What is the best way to start the game after some time like (30 seconds) after players join the session and with a good number of players to start the game?
2- What is the best way to get (timer variable) from (Game state or Game mode) to (Player Widget)?
It is important that the value is accurate with the other players.
3- What is the best way to know that the game is over as if one (Team or Player) is alive and all the others (Players and Bots) are dead, from (Game Mode or Game State)?
4- How can I get the number of alive(Players and Bots) from (Game Mode or Game State)
ShooterGame already does that. The players login as spectators and then when that timer that is fired on GameMode expires, it starts the game.
Widgets are local (client-only usually) that’s why you need an actor that replicates the info. GameState replicates, while GameMode doesn’t. Typically you fire the timer on GameState and replicate RemainingTime. Notice you don’t replicate the TimerHandle itself as that’s local. For accuracy read this.
GameMode is the class that defines game rules and decides such stuff accordingly. GameState holds and replicates the state of the game as its name suggests.
Inside GameState you have an array called PlayerArray. Get its size to know how many players (not bots) are there. If you want to include bots, then the AIController that owns the bot has to set bWantsPlayerState = true in its constructor. To do the bot part in BP, you would have to keep track of all the bots with an array in GameState. For example, BotArray. You will probably have to use GetAllActorsOfClass to get the bots.
My point still stands on reading that compendium I suggested to you in the other thread.