<?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%2Fporting</id>
	<title>Unity.Multiplayer/articles/porting - 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%2Fporting"/>
	<link rel="alternate" type="text/html" href="https://mindattic.com/wiki/docs/index.php?title=Unity.Multiplayer/articles/porting&amp;action=history"/>
	<updated>2026-12-05T08:03:58Z</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/porting&amp;diff=934&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/porting&amp;diff=934&amp;oldid=prev"/>
		<updated>2026-11-29T20:37:11Z</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;= Porting a game =&lt;br /&gt;
&lt;br /&gt;
A guide for moving an existing Unity game — single-player, or already networked some other way — onto &amp;lt;code&amp;gt;Unity.Multiplayer&amp;lt;/code&amp;gt;. The order below is the one that keeps the game running (and testable) at every step, not one everything-at-once rewrite.&lt;br /&gt;
&lt;br /&gt;
== 1. Separate state from presentation, if it isn&amp;#039;t already ==&lt;br /&gt;
&lt;br /&gt;
The package&amp;#039;s one rule is &amp;lt;strong&amp;gt;the server owns shared state; clients send what they want to happen&amp;lt;/strong&amp;gt; (BIBLE UM-LAW-1). Before touching any networking code, it&amp;#039;s worth knowing which of the game&amp;#039;s fields are:&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;strong&amp;gt;Shared state&amp;lt;/strong&amp;gt; everyone must agree on (position, health, score, whose turn it is) — this becomes &amp;lt;code&amp;gt;[Synced]&amp;lt;/code&amp;gt; fields, written only on the server.&lt;br /&gt;
* &amp;lt;strong&amp;gt;Player intent&amp;lt;/strong&amp;gt; (move this way, grab that thing, press this button) — this becomes &amp;lt;code&amp;gt;[ToServer]&amp;lt;/code&amp;gt; calls.&lt;br /&gt;
* &amp;lt;strong&amp;gt;Purely local presentation&amp;lt;/strong&amp;gt; (camera shake, a particle effect, UI the player&amp;#039;s own client drives) — this stays ordinary, un-networked code.&lt;br /&gt;
&lt;br /&gt;
A single-player game that already separates &amp;quot;the simulation&amp;quot; from &amp;quot;the view&amp;quot; (a &amp;lt;code&amp;gt;GameState&amp;lt;/code&amp;gt; class a &amp;lt;code&amp;gt;MonoBehaviour&amp;lt;/code&amp;gt; reads from, say) usually only needs its simulation fields marked &amp;lt;code&amp;gt;[Synced]&amp;lt;/code&amp;gt; and its input calls turned into &amp;lt;code&amp;gt;[ToServer]&amp;lt;/code&amp;gt; methods — the simulation code itself barely changes. A game whose state and presentation are the same &amp;lt;code&amp;gt;MonoBehaviour&amp;lt;/code&amp;gt; fields benefits from pulling the state out first, as its own exercise, before adding networking on top of it.&lt;br /&gt;
&lt;br /&gt;
== 2. Make the player object a &amp;lt;code&amp;gt;NetEntity&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;// before&lt;br /&gt;
public class PlayerController : MonoBehaviour { ... }&lt;br /&gt;
&lt;br /&gt;
// after&lt;br /&gt;
public partial class PlayerController : NetEntity { ... }&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;NetEntity&amp;lt;/code&amp;gt; requires a &amp;lt;code&amp;gt;NetworkObject&amp;lt;/code&amp;gt; on the same GameObject (&amp;lt;strong&amp;gt;MindAttic ▸ Multiplayer ▸ Validate Prefabs&amp;lt;/strong&amp;gt; checks this) and the class itself, and every class it derives from, must not be generic ([[Unity.Multiplayer/articles/attributes#Generator diagnostics|MAMP005]]). Override &amp;lt;code&amp;gt;OnSpawned&amp;lt;/code&amp;gt; / &amp;lt;code&amp;gt;OnDespawned&amp;lt;/code&amp;gt; instead of any &amp;lt;code&amp;gt;OnNetworkSpawn&amp;lt;/code&amp;gt;/&amp;lt;code&amp;gt;OnNetworkDespawn&amp;lt;/code&amp;gt; you had — &amp;lt;code&amp;gt;NetEntity&amp;lt;/code&amp;gt; seals those so its own &amp;lt;code&amp;gt;[Synced]&amp;lt;/code&amp;gt; wiring always runs.&lt;br /&gt;
&lt;br /&gt;
== 3. Turn input into &amp;lt;code&amp;gt;[ToServer]&amp;lt;/code&amp;gt; calls ==&lt;br /&gt;
&lt;br /&gt;
Wherever the old code read input and changed shared state directly on every client (common in a prototype, or a game that was never networked at all), split it in two: the client sends intent, the server applies it.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre class=&amp;quot;md-code lang-csharp&amp;quot;&amp;gt;// before (single-player / client-authoritative)&lt;br /&gt;
void Update()&lt;br /&gt;
{&lt;br /&gt;
    if (Input.GetKeyDown(KeyCode.Space)) Jump();&lt;br /&gt;
}&lt;br /&gt;
void Jump() { _velocity.y = jumpForce; }&lt;br /&gt;
&lt;br /&gt;
// after&lt;br /&gt;
void Update()&lt;br /&gt;
{&lt;br /&gt;
    if (Input.GetKeyDown(KeyCode.Space)) Jump(); // owner calls the partial method&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
[ToServer]&lt;br /&gt;
public partial void Jump();&lt;br /&gt;
&lt;br /&gt;
private void OnJump(NetSender sender)&lt;br /&gt;
{&lt;br /&gt;
    _velocity.y = jumpForce; // only the server actually applies it&lt;br /&gt;
}&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
See [[Unity.Multiplayer/articles/attributes|Attributes reference]] for &amp;lt;code&amp;gt;RateLimit&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;Burst&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;RequireOwnership&amp;lt;/code&amp;gt; — input that fires every frame (movement) usually wants a rate limit; a once-per-match action (a vote, a ready check) usually wants &amp;lt;code&amp;gt;RequireOwnership = false&amp;lt;/code&amp;gt; so any connected player can call it.&lt;br /&gt;
&lt;br /&gt;
== 4. Turn shared fields into &amp;lt;code&amp;gt;[Synced]&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;// before&lt;br /&gt;
public Vector3 Position;&lt;br /&gt;
&lt;br /&gt;
// after&lt;br /&gt;
[Synced] private Vector3 _position;&lt;br /&gt;
// use the generated `Position` property everywhere; never the field&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The generator rejects a direct write to the field from anywhere ([[Unity.Multiplayer/articles/attributes#Generator diagnostics|MAMP006]]) and warns on a direct read ([[Unity.Multiplayer/articles/attributes#Generator diagnostics|MAMP007]]), so a search-and-replace that misses a spot is a build error or warning, not a silent desync. Add &amp;lt;code&amp;gt;OnChanged = nameof(Handler)&amp;lt;/code&amp;gt; wherever the old code ran logic on the value changing (an animator trigger, a UI refresh).&lt;br /&gt;
&lt;br /&gt;
== 5. Wire up the scene ==&lt;br /&gt;
&lt;br /&gt;
Run &amp;lt;strong&amp;gt;MindAttic ▸ Multiplayer ▸ Set Up Scene&amp;lt;/strong&amp;gt; once per scene that needs networking: it adds a NetworkManager with Unity Transport and a &amp;lt;code&amp;gt;NetBootstrap&amp;lt;/code&amp;gt;, and assigns a &amp;lt;code&amp;gt;NetPrefabList&amp;lt;/code&amp;gt; of the scene&amp;#039;s NetworkObject prefabs. Then either replace the game&amp;#039;s multiplayer menus with the [[Unity.Multiplayer/articles/front-end|drop-in front end]] (&amp;lt;strong&amp;gt;MindAttic ▸ Multiplayer ▸ Add Front End&amp;lt;/strong&amp;gt;: host, join by IP or code, lobby, connection dialogs, reconnect and an Esc menu, with the game&amp;#039;s own options added through its hooks), or point the game&amp;#039;s existing menu/lobby UI at the &amp;lt;code&amp;gt;NetBootstrap&amp;lt;/code&amp;gt; instance instead of whatever custom connect/host code it had — see [[Unity.Multiplayer/articles/getting-started#Drive it from your own UI|Getting started]] for the exact calls (&amp;lt;code&amp;gt;StartHost&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;JoinByAddress&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;HostWithCode&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;JoinByCode&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;Leave&amp;lt;/code&amp;gt;) and the events to show connection state and errors (&amp;lt;code&amp;gt;Ended&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;JoinCodeFailed&amp;lt;/code&amp;gt;, and &amp;lt;code&amp;gt;DisconnectText&amp;lt;/code&amp;gt; for the words).&lt;br /&gt;
&lt;br /&gt;
If the game changes scenes while a session is live, turn on &amp;lt;strong&amp;gt;Enable Scene Management&amp;lt;/strong&amp;gt; on the NetworkManager and drive it through &amp;lt;code&amp;gt;NetSession.Scenes&amp;lt;/code&amp;gt; (&amp;lt;code&amp;gt;Load&amp;lt;/code&amp;gt;/&amp;lt;code&amp;gt;Unload&amp;lt;/code&amp;gt;), not Unity&amp;#039;s own &amp;lt;code&amp;gt;SceneManager&amp;lt;/code&amp;gt; — only the server may change scenes, and &amp;lt;code&amp;gt;NetSceneFlow&amp;lt;/code&amp;gt; is what keeps late joiners synchronized to whatever scene is already loaded.&lt;br /&gt;
&lt;br /&gt;
== 6. Carry over anything that needs the same player back after a reconnect ==&lt;br /&gt;
&lt;br /&gt;
If the old game already had a concept of &amp;quot;whose character is this&amp;quot; (a save slot, a player index), map it onto the package&amp;#039;s player token (&amp;lt;code&amp;gt;PlayerIdentity&amp;lt;/code&amp;gt;, kept in &amp;lt;code&amp;gt;PlayerPrefs&amp;lt;/code&amp;gt; by &amp;lt;code&amp;gt;NetBootstrap&amp;lt;/code&amp;gt;&amp;#039;s &amp;lt;strong&amp;gt;Remember Player&amp;lt;/strong&amp;gt; option) so a dropped player reconnecting gets the same seat and the same player object back rather than a fresh one. See [[Unity.Multiplayer/articles/reconnect-seats|Reconnect and seats]].&lt;br /&gt;
&lt;br /&gt;
== 7. Replace any existing netcode transport last ==&lt;br /&gt;
&lt;br /&gt;
If the game was already built on raw Netcode for GameObjects (custom RPCs, hand-rolled &amp;lt;code&amp;gt;NetworkVariable&amp;lt;/code&amp;gt;s), port one entity at a time: leave the untouched ones on their existing NGO code while a given &amp;lt;code&amp;gt;NetEntity&amp;lt;/code&amp;gt; subclass moves to attributes, since both can coexist on the same &amp;lt;code&amp;gt;NetworkManager&amp;lt;/code&amp;gt; during the migration. Once every networked type is a &amp;lt;code&amp;gt;NetEntity&amp;lt;/code&amp;gt;, the game never references &amp;lt;code&amp;gt;Unity.Netcode&amp;lt;/code&amp;gt; directly again outside the adapter it&amp;#039;s already depending on (BIBLE UM-LAW-2) — any custom rate limiting, approval or reconnect logic the old code had can be deleted in favor of the package&amp;#039;s own (see [[Unity.Multiplayer/articles/reconnect-seats#Connection approval|Reconnect and seats]]).&lt;br /&gt;
&lt;br /&gt;
== 8. Test as you go, then package for hosting ==&lt;br /&gt;
&lt;br /&gt;
Write a small PlayMode suite against the game&amp;#039;s own entities on the package&amp;#039;s test kit (&amp;lt;code&amp;gt;NetSessionTest&amp;lt;/code&amp;gt;), the same way &amp;lt;code&amp;gt;tests/MinimalSample/Tests&amp;lt;/code&amp;gt; does against &amp;lt;code&amp;gt;MinimalPlayer&amp;lt;/code&amp;gt; — see [[Unity.Multiplayer/articles/testing#The test kit|Testing]]. Once the game plays correctly in a listen server, &amp;lt;strong&amp;gt;MindAttic ▸ Multiplayer ▸ Build Dedicated Server (Linux)&amp;lt;/strong&amp;gt; and &amp;lt;strong&amp;gt;Build Server Package&amp;lt;/strong&amp;gt; get it onto a real host; see [[Unity.Multiplayer/articles/topologies|Topologies]] and [[Unity.Multiplayer/articles/hosting|Hosting]].&lt;br /&gt;
&lt;br /&gt;
== A worked example ==&lt;br /&gt;
&lt;br /&gt;
MindAttic&amp;#039;s own co-op physics puzzle, Cursory, was ported from an ASP.NET Blazor Server + SignalR prototype onto this package as [[Unity.Cursory|Unity.Cursory]] (its UC-T3 through UC-T15 tickets; see [[Unity.Multiplayer/rfc/0001-architecture#UnityCursory (public)|RFC 0001 § UnityCursory]] for the mapping from the old simulation to this package&amp;#039;s &amp;lt;code&amp;gt;[Synced]&amp;lt;/code&amp;gt;/&amp;lt;code&amp;gt;[ToServer]&amp;lt;/code&amp;gt; surface). [[Unity.Multiplayer/articles/case-study-cursory|Case study: Unity.Cursory]] walks through how the finished game uses each piece of the [[Unity.Multiplayer/articles/kit|kit]], with links to its files, and ends with a table of what to copy into your own 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/porting.md Unity.Multiplayer/docs/articles/porting.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>