Search public documentation:
- Replication Infos
- When to use the replication info pattern?
ReplicationInfos are actors that are automatically replicated on all clients. They provide a communication pathway between clients and servers.
PlayerReplicationInfos are needed because while clients can communicate directly with servers; clients are not able to directly communicate with other clients. This is because only the client's PlayerController exists for the client. PlayerReplicationInfo's however exist on every client and are updated on the client when any server side variables changes. Thus, if a player needs to know anything about the another player, the player can just look it up in that player's PlayerReplicationInfo.
- Score - Player's score.
- Deaths - Number of times the player has died.
- PlayerName - Player's name.
- Team - Team the player is on.
- bAdmin - Is the player an administrator for the game?
- bIsSpectator - Is the player a spectator?
- bOnlySpectator - Can this player only ever be a spectator?
- bWaitingPlayer - Is the player waiting to enter the game?
- bReadyToPlay - Is the player ready to play?
- StartTime - Elapsed time on the server of when this player replication info was first created.
- bOutOfLives - Is the player out of lives?
- UniqueId - Id used by the network to uniquely identify a player.
- Ping - Replicated compressed ping for this player.
- PlayerID - Player's unique id number.
- bBot - Is the player actually a bot?
- bIsInactive - Did this PRI come from the GameInfo's InactivePRIArray?
GameReplicationInfos are needed because GameInfos are never replicated to the client. Because the client still needs to know some information about the GameInfo, GameReplicationInfos are created on the server and the clients. Thus whenever the GameInfo is updated and needs to inform clients of these updates, the GameInfo can push those updates to the GameReplicationInfo. When the client's version of GameReplicationInfo is updated, the client then has those updates.
- bStopCountDown - If true, stop the remaining time countdown.
- Winner - The winner of the game.
- bMatchHasBegun - Is the match is in progress?
- bMatchIsOver - Is the match over?
- RemainingMinute - Used for counting down time in time limited games.
- GameClass - Class of the server's GameInfo.
- RemainingTime - Used for counting down time in time limited games.
- ElapsedTime - Used for counting down time in time limited games.
- GoalScore - Current score.
- TimeLimit - The time limit for this match.
- ServerName - Name of the server.
TeamInfos contain information about team structures used by team based games such as Capture the flag. Much like PlayerReplicationInfo, it is used to communicate common data between players.
- Score - The team's score.
- TeamName - Name of the team.
- TeamIndex - Index of the team.
- When actors may not exist on all clients.
- GameInfo does not exist on clients.
- PlayerController only exist on the owning client.
- When you want to do client to client communication.
- All players can view their team information, and switch between teams.
ReplicationInfos solve the problem where instances of classes may only exist on the server, only on the client or only on a single client. This is why network testing of your multiplayer game must start right at the beginning. It's very easy to fall into the trap where things work in single player or with a server and single client but then fail to work when there are more clients involved. Planning your classes in relation to networking is a good step in ensuring that you won't have headaches later on in development.