<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://mindattic.com/wiki/docs/index.php?action=history&amp;feed=atom&amp;title=Unity.Multiplayer%2Farticles%2Fplayers</id>
	<title>Unity.Multiplayer/articles/players - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://mindattic.com/wiki/docs/index.php?action=history&amp;feed=atom&amp;title=Unity.Multiplayer%2Farticles%2Fplayers"/>
	<link rel="alternate" type="text/html" href="https://mindattic.com/wiki/docs/index.php?title=Unity.Multiplayer/articles/players&amp;action=history"/>
	<updated>2026-12-05T11:33:02Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.46.3</generator>
	<entry>
		<id>https://mindattic.com/wiki/docs/index.php?title=Unity.Multiplayer/articles/players&amp;diff=933&amp;oldid=prev</id>
		<title>Docs Sync: md2wiki: sync from MindAttic.Docs</title>
		<link rel="alternate" type="text/html" href="https://mindattic.com/wiki/docs/index.php?title=Unity.Multiplayer/articles/players&amp;diff=933&amp;oldid=prev"/>
		<updated>2026-11-29T20:37:09Z</updated>

		<summary type="html">&lt;p&gt;md2wiki: sync from MindAttic.Docs&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;= Players: names, colours and the roster =&lt;br /&gt;
&lt;br /&gt;
Every multiplayer game needs to know who is playing: a name over each character, a colour for each team mate, a scoreboard, a ping column, a &amp;quot;you&amp;quot; marker. &amp;lt;code&amp;gt;NetRoster&amp;lt;/code&amp;gt; is that list, on every peer, kept in step by the server. A game never copies names and colours onto its own networked objects to get them to the clients.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre class=&amp;quot;md-code lang-csharp&amp;quot;&amp;gt;NetRoster roster = session.Roster;          // or NetRoster.Current, for NetBootstrap.Instance&amp;#039;s session&lt;br /&gt;
&lt;br /&gt;
foreach (NetPlayer player in roster.All)    // by seat&lt;br /&gt;
{&lt;br /&gt;
    Debug.Log(player.DisplayName + &amp;quot; &amp;quot; + PlayerColors.ToHex(player.Color) + &amp;quot; &amp;quot; + player.PingMs + &amp;quot; ms&amp;quot;&lt;br /&gt;
        + (player.IsHost ? &amp;quot; (host)&amp;quot; : &amp;quot;&amp;quot;) + (player.IsLocal ? &amp;quot; (you)&amp;quot; : &amp;quot;&amp;quot;));&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
NetPlayer me = roster.Local;                // null on a dedicated server&lt;br /&gt;
roster.TryGet(OwnerClientId, out NetPlayer owner);  // by connection&lt;br /&gt;
roster.TryGetBySeat(seatIndex, out NetPlayer inSeat); // by seat: stable across a reconnect&lt;br /&gt;
&lt;br /&gt;
roster.Joined  += player =&amp;gt; AddNameTag(player);&lt;br /&gt;
roster.Left    += player =&amp;gt; RemoveNameTag(player);&lt;br /&gt;
roster.Changed += change =&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    if (change.OnlyPingChanged) return;     // the round trip is re-measured every second&lt;br /&gt;
    UpdateNameTag(change.Player);           // a rename, a new colour, dropped or back&lt;br /&gt;
};&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== What a player record holds ==&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! &amp;lt;code&amp;gt;NetPlayer&amp;lt;/code&amp;gt;&lt;br /&gt;
! What it is&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;Seat&amp;lt;/code&amp;gt;&lt;br /&gt;
| The seat index. It identifies the player for as long as the seat lives, across reconnects.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;ClientId&amp;lt;/code&amp;gt;&lt;br /&gt;
| The connection the player is on now. It changes when they reconnect.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;DisplayName&amp;lt;/code&amp;gt;&lt;br /&gt;
| The name everyone sees.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;Color&amp;lt;/code&amp;gt;&lt;br /&gt;
| The colour everyone draws them in: their own, or their seat&amp;#039;s palette colour if they never picked one. &amp;lt;code&amp;gt;player.UnityColor()&amp;lt;/code&amp;gt; gives a &amp;lt;code&amp;gt;Color32&amp;lt;/code&amp;gt;.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;IsHost&amp;lt;/code&amp;gt;&lt;br /&gt;
| True for a listen server&amp;#039;s own player.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;IsConnected&amp;lt;/code&amp;gt;&lt;br /&gt;
| False while they have dropped and their seat is held for them (see [[Unity.Multiplayer/articles/reconnect-seats|Reconnect and seats]]).&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;PingMs&amp;lt;/code&amp;gt;&lt;br /&gt;
| Round trip to the server in milliseconds (0 for the host), or &amp;lt;code&amp;gt;NetPlayer.UnknownPing&amp;lt;/code&amp;gt; (-1) until measured.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;IsLocal&amp;lt;/code&amp;gt;&lt;br /&gt;
| True on the peer whose own player this is.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The record is immutable; the roster hands out a new one whenever something changes, and &amp;lt;code&amp;gt;Changed&amp;lt;/code&amp;gt; carries the record before and after (&amp;lt;code&amp;gt;NameChanged&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;ColorChanged&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;ConnectionChanged&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;OnlyPingChanged&amp;lt;/code&amp;gt;).&lt;br /&gt;
&lt;br /&gt;
== Where the name and colour come from ==&lt;br /&gt;
&lt;br /&gt;
A player sends their name and colour in the [[Unity.Multiplayer/articles/reconnect-seats#Connection approval|connection approval payload]] (&amp;lt;code&amp;gt;NetSession.Identity&amp;lt;/code&amp;gt;). The [[Unity.Multiplayer/articles/front-end|drop-in front end]] fills that from an &amp;lt;code&amp;gt;IPlayerIdentitySource&amp;lt;/code&amp;gt;, by default the player&amp;#039;s MindAttic profile (&amp;lt;code&amp;gt;Profiles.Current.Settings.Common.DisplayName&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;.Color&amp;lt;/code&amp;gt; from Unity.Shared). The server puts them on the player&amp;#039;s seat and builds the roster from the seats:&lt;br /&gt;
&lt;br /&gt;
* the name is cleaned with &amp;lt;code&amp;gt;PlayerNames.Clean&amp;lt;/code&amp;gt; (invisible characters dropped, single spaces, at most 32 characters), so an odd name never stops anyone from joining;&lt;br /&gt;
* a player who never picked a colour (the default white, &amp;lt;code&amp;gt;PlayerColor.White&amp;lt;/code&amp;gt;) is drawn in their seat&amp;#039;s colour from &amp;lt;code&amp;gt;PlayerColors.Palette&amp;lt;/code&amp;gt;, eight colours that read well on dark and light, so neighbours never share one.&lt;br /&gt;
&lt;br /&gt;
== How it reaches every peer ==&lt;br /&gt;
&lt;br /&gt;
The server sends the whole roster to each connection once it is in (a late joiner and a returning player get everything), then only what changes. It travels in named messages beside the game&amp;#039;s own traffic, so there is no prefab or &amp;lt;code&amp;gt;NetworkObject&amp;lt;/code&amp;gt; to register and it works in any scene. The server measures each client&amp;#039;s round trip once a second and updates &amp;lt;code&amp;gt;PingMs&amp;lt;/code&amp;gt; when it moves by 5 ms or more. When the session ends, the peer&amp;#039;s roster empties and &amp;lt;code&amp;gt;Left&amp;lt;/code&amp;gt; fires for each player.&lt;br /&gt;
&lt;br /&gt;
A player who drops keeps their record, &amp;lt;code&amp;gt;IsConnected&amp;lt;/code&amp;gt; false, for as long as their seat is held. When they come back with the same player token they get the same seat and the same record (with their new &amp;lt;code&amp;gt;ClientId&amp;lt;/code&amp;gt;): other peers see a &amp;lt;code&amp;gt;Changed&amp;lt;/code&amp;gt;, never a &amp;lt;code&amp;gt;Left&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;Joined&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== Changing a name or colour mid-game ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre class=&amp;quot;md-code lang-csharp&amp;quot;&amp;gt;PlayerChangeResult result = await session.Roster.RequestChange(&amp;quot;Bobby&amp;quot;, PlayerColors.Palette[2]);&lt;br /&gt;
if (!result.Accepted)&lt;br /&gt;
{&lt;br /&gt;
    ShowToast(result.Reason);               // &amp;quot;A name cannot contain invisible or unprintable characters.&amp;quot;&lt;br /&gt;
}&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Pass &amp;lt;code&amp;gt;null&amp;lt;/code&amp;gt; for the part that stays. The server is the judge ([[Unity.Multiplayer/BIBLE#UM-LAW-1 — The server owns state|UM-LAW-1]]); it checks every request with &amp;lt;code&amp;gt;PlayerChangeRequest.Validate&amp;lt;/code&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;strong&amp;gt;Name&amp;lt;/strong&amp;gt; (&amp;lt;code&amp;gt;PlayerNames.Validate&amp;lt;/code&amp;gt;): 1 to 32 characters; letters and digits in any script, combining marks, punctuation and symbols (emoji too); single plain spaces between words. Refused: an empty name, a leading or trailing space, two spaces in a row, other kinds of blank space and line breaks, control and invisible formatting characters (zero-width spaces and joiners, direction overrides), private-use and unassigned code points, broken surrogate pairs.&lt;br /&gt;
* &amp;lt;strong&amp;gt;Colour&amp;lt;/strong&amp;gt; (&amp;lt;code&amp;gt;PlayerColors.Validate&amp;lt;/code&amp;gt;): fully opaque. &amp;lt;code&amp;gt;PlayerColors.TryParse(&amp;quot;#3498DB&amp;quot;)&amp;lt;/code&amp;gt; reads &amp;lt;code&amp;gt;#RRGGBB&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;#RRGGBBAA&amp;lt;/code&amp;gt;.&lt;br /&gt;
* &amp;lt;strong&amp;gt;Rate&amp;lt;/strong&amp;gt;: at most 5 changes at once, then one a second, per player.&lt;br /&gt;
&lt;br /&gt;
An accepted change is kept with the seat and in the player&amp;#039;s own &amp;lt;code&amp;gt;NetSession.Identity&amp;lt;/code&amp;gt;, so a reconnect brings it back, and every peer gets a &amp;lt;code&amp;gt;Changed&amp;lt;/code&amp;gt;. The answer arrives after the roster update, so &amp;lt;code&amp;gt;result.Player&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;roster.Local&amp;lt;/code&amp;gt; already show the new name. A host&amp;#039;s own change is applied at once.&lt;br /&gt;
&lt;br /&gt;
The front end does this for you: its Settings screen, opened mid-game, asks the server, shows a refusal as a toast, and saves an accepted change back to the player&amp;#039;s &amp;lt;code&amp;gt;IPlayerIdentitySource&amp;lt;/code&amp;gt; (their MindAttic profile by default). It saves any accepted change of the local player&amp;#039;s name or colour the same way, including one a game makes with &amp;lt;code&amp;gt;RequestChange&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== The rules are plain C# ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;PlayerNames&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;PlayerColors&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;PlayerRoster&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;RosterWire&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;NetPlayer&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;PlayerChangeRequest&amp;lt;/code&amp;gt; live in the engine-free Core assembly, so a game&amp;#039;s own tools and tests can use them without Unity.&lt;br /&gt;
&lt;br /&gt;
== Where it is tested ==&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;dotnet test tests/Core.Tests&amp;lt;/code&amp;gt;: &amp;lt;code&amp;gt;PlayerNamesTests&amp;lt;/code&amp;gt; (accepted and refused names, cleaning), &amp;lt;code&amp;gt;PlayerColorsTests&amp;lt;/code&amp;gt; (palette, seat colours, hex, opacity, change requests), &amp;lt;code&amp;gt;PlayerRosterTests&amp;lt;/code&amp;gt; (joined, left and changed from a replacement, snapshots, held seats, &amp;lt;code&amp;gt;NetPlayer.FromSeat&amp;lt;/code&amp;gt;, a seat keeping a rename) and &amp;lt;code&amp;gt;RosterWireTests&amp;lt;/code&amp;gt; (round trips, malformed bytes refused without throwing).&lt;br /&gt;
* &amp;lt;code&amp;gt;tests/run-playmode.ps1&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;RosterTests&amp;lt;/code&amp;gt;: a host and two clients over real Unity Transport. Names and colours on every peer, including a late joiner; round trips measured; a rename reaching everyone; bad names and a see-through colour refused by the server; a reconnect keeping seat, name and colour; a kick removing the player everywhere. &amp;lt;code&amp;gt;NetFrontEndTests&amp;lt;/code&amp;gt;: the lobby follows the roster, and a rename from the in-game Settings reaches the host&amp;#039;s lobby and is saved to the player&amp;#039;s identity once accepted.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class=&amp;quot;md2wiki-crumb&amp;quot;&amp;gt;Part of [[Unity.Multiplayer]].&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class=&amp;quot;md2wiki-source&amp;quot;&amp;gt;From [https://github.com/mindattic/Unity.Multiplayer/blob/main/docs/articles/players.md Unity.Multiplayer/docs/articles/players.md] via MindAttic.Docs; synced automatically, so edit the repo, not this page.&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Category:Unity.Multiplayer]]&lt;/div&gt;</summary>
		<author><name>Docs Sync</name></author>
	</entry>
</feed>