Get Local Player

public Player GetLocalPlayer()

Returns a Player object with information about the local player (who controls units from the PC). From this object you can get the player’s resources and other info about the local player.

A shorthand LocalPlayer property, returning the same value, is also available.

Example

[Inject] PlayersService players;

// this example code can be run from any script

Player localPlayer = players.GetLocalPlayer(); // getting local player, same as players.LocalPlayer

Debug.Log("Local player name: " + localPlayer.UserName); // log to console name of local Player