<?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%2Fvotes</id>
	<title>Unity.Multiplayer/articles/votes - 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%2Fvotes"/>
	<link rel="alternate" type="text/html" href="https://mindattic.com/wiki/docs/index.php?title=Unity.Multiplayer/articles/votes&amp;action=history"/>
	<updated>2026-12-05T11:00:24Z</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/votes&amp;diff=939&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/votes&amp;diff=939&amp;oldid=prev"/>
		<updated>2026-11-29T20:37:16Z</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;= Votes =&lt;br /&gt;
&lt;br /&gt;
Most multiplayer games end up needing a vote: restart the round, skip the map, change the level, remove a griefer. The votes kit is that whole feature: the rules in plain C#, a server-authoritative &amp;lt;code&amp;gt;VoteBoard&amp;lt;/code&amp;gt; every peer sees, a built-in kick, and a ready-made overlay with the question, the tally and Yes / No. A game only says which votes it offers and what happens when one passes.&lt;br /&gt;
&lt;br /&gt;
== Add it (one minute) ==&lt;br /&gt;
&lt;br /&gt;
# Select the GameObject with your &amp;lt;code&amp;gt;NetBootstrap&amp;lt;/code&amp;gt; and &amp;lt;strong&amp;gt;Add Component ▸ MindAttic ▸ Multiplayer ▸ Net Votes&amp;lt;/strong&amp;gt;.&lt;br /&gt;
# Register your votes, on any peer, at any time (only the server&amp;#039;s registrations matter):&amp;lt;br&amp;gt;&amp;lt;pre class=&amp;quot;md-code lang-csharp&amp;quot;&amp;gt;NetVotes votes = NetVotes.Instance; votes.AddKind(new VoteKind(&amp;quot;restart&amp;quot;, &amp;quot;Restart the round?&amp;quot;) { Passed = v =&amp;gt; RestartRound() });&amp;lt;/pre&amp;gt;&lt;br /&gt;
# Start one from any peer, for example from a button:&amp;lt;br&amp;gt;&amp;lt;pre class=&amp;quot;md-code lang-csharp&amp;quot;&amp;gt;NetVotes.Instance.Board.StartVote(&amp;quot;restart&amp;quot;);&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
That is all. With the [[Unity.Multiplayer/articles/front-end|drop-in front end]] in the scene, the overlay appears by itself in game: the question, &amp;quot;Yes 1 · No 0 · needs 2 of 3 · 12 s&amp;quot;, a bar towards the quorum, Yes and No, and a toast with the result. Without the front end, see [[#Your own UI|Your own UI]].&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;NetVotes&amp;lt;/code&amp;gt; registers the package&amp;#039;s own &amp;lt;code&amp;gt;VoteBoard&amp;lt;/code&amp;gt; prefab on every peer before the session starts, spawns the board on the server once it runs, and serves it with the Inspector&amp;#039;s rules. A dedicated server, a host and a client all run the same scene.&lt;br /&gt;
&lt;br /&gt;
== The rules ==&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Rule&lt;br /&gt;
! Default&lt;br /&gt;
! Inspector / code&lt;br /&gt;
|-&lt;br /&gt;
| Quorum&lt;br /&gt;
| two thirds of the voters, rounded up: 1 of 1, 2 of 2, 2 of 3, 3 of 4, 4 of 5, 4 of 6&lt;br /&gt;
| &amp;lt;strong&amp;gt;Quorum Fraction&amp;lt;/strong&amp;gt; / &amp;lt;code&amp;gt;VoteRules.QuorumFraction&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Time limit&lt;br /&gt;
| 15 s, on the session&amp;#039;s tick clock&lt;br /&gt;
| &amp;lt;strong&amp;gt;Timeout Seconds&amp;lt;/strong&amp;gt; / &amp;lt;code&amp;gt;VoteRules.TimeoutSeconds&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Cooldown&lt;br /&gt;
| none; a player whose vote failed waits this long before starting another (others are not held up)&lt;br /&gt;
| &amp;lt;strong&amp;gt;Cooldown Seconds&amp;lt;/strong&amp;gt; / &amp;lt;code&amp;gt;VoteRules.CooldownSeconds&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Who may start&lt;br /&gt;
| any player in the game&lt;br /&gt;
| &amp;lt;strong&amp;gt;Host Only&amp;lt;/strong&amp;gt; / &amp;lt;code&amp;gt;VoteRules.MayStart = id =&amp;gt; ...&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| The starter&amp;#039;s vote&lt;br /&gt;
| starting counts as Yes&lt;br /&gt;
| &amp;lt;code&amp;gt;VoteRules.StarterVotesYes&amp;lt;/code&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
And always:&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;strong&amp;gt;One vote at a time.&amp;lt;/strong&amp;gt; Starting another while one runs is refused.&lt;br /&gt;
* &amp;lt;strong&amp;gt;The roster is fixed when the vote starts.&amp;lt;/strong&amp;gt; A player who joins later does not vote on it.&lt;br /&gt;
* &amp;lt;strong&amp;gt;It passes as soon as Yes reaches the quorum&amp;lt;/strong&amp;gt;, and is &amp;lt;strong&amp;gt;rejected as soon as it no longer can&amp;lt;/strong&amp;gt;, even if every undecided voter said Yes. Nobody waits for the timer when the result is already certain.&lt;br /&gt;
* &amp;lt;strong&amp;gt;A voter who leaves is dropped&amp;lt;/strong&amp;gt; and the quorum is recomputed from who is left, which can pass or reject the vote at once. A vote whose last voter leaves is abandoned.&lt;br /&gt;
* &amp;lt;strong&amp;gt;Players may change their mind.&amp;lt;/strong&amp;gt; A second ballot replaces the first (the overlay disables its buttons once you have voted, as most games do).&lt;br /&gt;
&lt;br /&gt;
== Vote kinds ==&lt;br /&gt;
&lt;br /&gt;
A &amp;lt;code&amp;gt;VoteKind&amp;lt;/code&amp;gt; is one vote a game offers. Only &amp;lt;code&amp;gt;id&amp;lt;/code&amp;gt; and the question are required:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre class=&amp;quot;md-code lang-csharp&amp;quot;&amp;gt;board.AddKind(new VoteKind(&amp;quot;level&amp;quot;, r =&amp;gt; &amp;quot;Switch to Level &amp;quot; + r.Number + &amp;quot;?&amp;quot;)&lt;br /&gt;
{&lt;br /&gt;
    Description = r =&amp;gt; levels.Name((int)r.Number),                                   // optional second line&lt;br /&gt;
    Check       = r =&amp;gt; levels.Exists((int)r.Number) ? null : &amp;quot;There is no level &amp;quot; + r.Number + &amp;quot;.&amp;quot;,&lt;br /&gt;
    MayVote     = (r, clientId) =&amp;gt; true,                                              // who votes (default: everyone)&lt;br /&gt;
    Passed      = v =&amp;gt; levels.Load((int)v.Number),                                    // runs on the server&lt;br /&gt;
    QuorumFraction = 0.5,                                                             // optional, this kind only&lt;br /&gt;
    TimeoutSeconds = 20,                                                              // optional, this kind only&lt;br /&gt;
});&lt;br /&gt;
&lt;br /&gt;
board.StartVote(&amp;quot;level&amp;quot;, 3);                // a number payload&lt;br /&gt;
board.StartVote(&amp;quot;map&amp;quot;, text: &amp;quot;Docks&amp;quot;);      // or a text payload&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Member&lt;br /&gt;
! What it does&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;Id&amp;lt;/code&amp;gt;&lt;br /&gt;
| What clients pass to &amp;lt;code&amp;gt;StartVote&amp;lt;/code&amp;gt;.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;Title(request)&amp;lt;/code&amp;gt;&lt;br /&gt;
| The question every peer sees, worded on the server when the vote starts.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;Description(request)&amp;lt;/code&amp;gt;&lt;br /&gt;
| An optional second line.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;Check(request)&amp;lt;/code&amp;gt;&lt;br /&gt;
| Null when the request is fine, else the sentence the starter is told (a level that does not exist, a player who already left).&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;MayVote(request, clientId)&amp;lt;/code&amp;gt;&lt;br /&gt;
| Who votes; the quorum counts only them. The kick vote leaves its target out.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;Passed(vote)&amp;lt;/code&amp;gt;&lt;br /&gt;
| What happens on the server when it passes, before any peer is told it passed.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;QuorumFraction&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;TimeoutSeconds&amp;lt;/code&amp;gt;&lt;br /&gt;
| This kind&amp;#039;s own rules instead of the board&amp;#039;s.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
A request carries the kind&amp;#039;s id, who asked (&amp;lt;code&amp;gt;StartedBy&amp;lt;/code&amp;gt;, filled in by the server), and an optional &amp;lt;code&amp;gt;long Number&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;string Text&amp;lt;/code&amp;gt;. Everything the server works out (title, description, quorum) reaches every peer, so clients need no registration of their own.&lt;br /&gt;
&lt;br /&gt;
== Kick ==&lt;br /&gt;
&lt;br /&gt;
The board has a built-in kick vote. &amp;lt;code&amp;gt;NetVotes&amp;lt;/code&amp;gt; adds it unless &amp;lt;strong&amp;gt;Kick Votes&amp;lt;/strong&amp;gt; is off; in code, &amp;lt;code&amp;gt;board.AddKickKind(reason)&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre class=&amp;quot;md-code lang-csharp&amp;quot;&amp;gt;board.StartKickVote(clientId);   // &amp;quot;Kick Bob?&amp;quot;&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Bob does not vote on his own kick, so with three players the two others must both say Yes. The host&amp;#039;s own player and the starter cannot be its target, and a player who has already left is refused. When it passes, the server removes the player with &amp;lt;code&amp;gt;NetSession.Kick&amp;lt;/code&amp;gt;; they see the front end&amp;#039;s &amp;quot;Removed from the game&amp;quot; dialog with the reason.&lt;br /&gt;
&lt;br /&gt;
== What every peer sees ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre class=&amp;quot;md-code lang-csharp&amp;quot;&amp;gt;VoteBoard board = VoteBoard.For(session);   // or NetVotes.Instance.Board&lt;br /&gt;
&lt;br /&gt;
board.Status        // VoteStatus or null: Kind, Title, Description, Number, Text, StartedBy, Yes, No, Voters, Quorum, SecondsLeft&lt;br /&gt;
board.IsVoteOpen&lt;br /&gt;
board.LocalChoice   // Undecided, Yes, No, or NotAVoter (joined after it started, or left out by the kind)&lt;br /&gt;
board.ChoiceOf(clientId)&lt;br /&gt;
&lt;br /&gt;
board.VoteChanged += status =&amp;gt; { };         // at most once a frame&lt;br /&gt;
board.VoteEnded   += result =&amp;gt; { };         // VoteResult: Ending (Passed, Rejected, TimedOut, Abandoned, Cancelled), counts&lt;br /&gt;
board.VoteRefused += (why, reason) =&amp;gt; { };  // only on the peer whose StartVote was refused&lt;br /&gt;
board.CastVote(true);&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
On the server, &amp;lt;code&amp;gt;board.Box&amp;lt;/code&amp;gt; is the Core &amp;lt;code&amp;gt;VoteBox&amp;lt;/code&amp;gt; itself, &amp;lt;code&amp;gt;board.CancelVote()&amp;lt;/code&amp;gt; calls a vote off, and &amp;lt;code&amp;gt;board.Rules&amp;lt;/code&amp;gt; holds the rules.&lt;br /&gt;
&lt;br /&gt;
== Your own UI ==&lt;br /&gt;
&lt;br /&gt;
The overlay is &amp;lt;code&amp;gt;Unity.Multiplayer.UI.VoteOverlay&amp;lt;/code&amp;gt; (MindAttic Components required). It is wired for you when the scene has a &amp;lt;code&amp;gt;NetFrontEnd&amp;lt;/code&amp;gt; with menus, and only shows in game. Without a front end, create it yourself:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre class=&amp;quot;md-code lang-csharp&amp;quot;&amp;gt;VoteBoard.Spawned += board =&amp;gt; { if (board.Session.IsClient) VoteOverlay.Create(board); };&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;VoteOverlay.AutoWire = false&amp;lt;/code&amp;gt; turns the automatic one off; &amp;lt;code&amp;gt;VoteOverlay.Created&amp;lt;/code&amp;gt; lets you move it (&amp;lt;code&amp;gt;TopOffset&amp;lt;/code&amp;gt;), hide it (&amp;lt;code&amp;gt;ShowWhen&amp;lt;/code&amp;gt;) or turn off its toasts. A game with its own UI binds to &amp;lt;code&amp;gt;board.Status&amp;lt;/code&amp;gt; and uses Core&amp;#039;s &amp;lt;code&amp;gt;VoteText&amp;lt;/code&amp;gt; for the same words: &amp;lt;code&amp;gt;VoteText.Tally(status)&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;VoteText.Standing(choice)&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;VoteText.Ended(result)&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;VoteText.Refused(refusal)&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
UI code that must not reference Netcode for GameObjects (like the overlay itself) binds to &amp;lt;code&amp;gt;IVoteBoard&amp;lt;/code&amp;gt;, which &amp;lt;code&amp;gt;VoteBoard&amp;lt;/code&amp;gt; implements, and finds boards through &amp;lt;code&amp;gt;VoteBoards.Spawned&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;VoteBoards.Despawned&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;VoteBoards.For(session)&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== Without NetVotes ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;NetVotes&amp;lt;/code&amp;gt; is three calls you can make yourself:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre class=&amp;quot;md-code lang-csharp&amp;quot;&amp;gt;VoteBoard.RegisterPrefab(session);                    // every peer, before the session starts&lt;br /&gt;
VoteBoard board = VoteBoard.Spawn(session, rules);    // the server, once it runs&lt;br /&gt;
board.AddKind(...).AddKickKind();&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;VoteBox&amp;lt;/code&amp;gt; (Core, engine-free) is the rules alone, for a bot, a single-player mode or a test: &amp;lt;code&amp;gt;new VoteBox(clock, rules)&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;Register(kind)&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;Start(new VoteRequest(&amp;quot;restart&amp;quot;, playerId), roster)&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;Cast&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;RemoveVoter&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;Cancel&amp;lt;/code&amp;gt;, and the &amp;lt;code&amp;gt;Changed&amp;lt;/code&amp;gt; / &amp;lt;code&amp;gt;Ended&amp;lt;/code&amp;gt; events.&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;VoteBoxTests&amp;lt;/code&amp;gt;): the quorum table and custom fractions, passing, early rejection, timeouts and the countdown, departures, one vote at a time, who may start, the cooldown, payloads, checks, voter filters, per-kind rules, cancel, and the overlay&amp;#039;s words.&lt;br /&gt;
* &amp;lt;code&amp;gt;tests/run-playmode.ps1&amp;lt;/code&amp;gt;: &amp;lt;code&amp;gt;VoteBoardTests&amp;lt;/code&amp;gt; (a host and two clients over real Unity Transport: a number payload passing and its effect on the server, a text payload with a description, early rejection, a timeout on a stepped clock, a player leaving mid-vote, refusals heard only by the starter, a kick vote removing its target, host-only starts), &amp;lt;code&amp;gt;NetVotesTests&amp;lt;/code&amp;gt; (the component beside a real &amp;lt;code&amp;gt;NetBootstrap&amp;lt;/code&amp;gt;) and, in &amp;lt;code&amp;gt;Unity.Multiplayer.UI.Tests&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;VoteOverlayTests&amp;lt;/code&amp;gt; (the overlay showing a vote and passing it from its Yes button, toasts, wiring itself with a front end in game).&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/votes.md Unity.Multiplayer/docs/articles/votes.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>