When a player joins the game mode creates a player controller and a player state. A player state reference is added to the game states player array. These typically should be indexed in the array according to join sort order.
In the controller class you should easily be able to get a specific player state via index with the following code.
In the event they are not correctly sorted (never assume they are) you can set a custom join ID in the game mode as the new player joins.
In the GM create a joins
int variable. Default it to 0.
In the PlayerState create a CustomPlayerID
int var…set it to replicate.
In the Game Mode use Event OnPostLogin
to Set the CustomPlayerID
and increment the Joins
int.
The CustomerPlayerID will be replicated, thus the GameState Player array will have a copy.
In the controller class create a TMap (Int, Your PS class obj ref)
New Function…
When the Game has started, all players are loaded, run the function.
You can then reference each player by a unique sorted ID integer.