๐Ÿ”ท My First Unity Game ยท Episode 8 of 8 ยท See All Episodes
๐ŸŒ Episode 8 ยท Series Finale ยท Netcode for GameObjects

Play Together!
Multiplayer Basics

The finale: real networked multiplayer with Unityโ€™s official Netcode, host and join, synced player movement, server authority, RPCs for effects, and a shared score. Two windows, one game.

๐Ÿ‘ถ Ages 12+ โฑ๏ธ ~2.5 Hours ๐Ÿ”ท Unity & C# โœ“ Free
๐Ÿ“ก Netcode setup ๐Ÿ–ฅ๏ธ Host & client ๐Ÿƒ Synced movement ๐Ÿ‘‘ Server authority ๐Ÿ“ฃ RPCs ๐Ÿ”ข NetworkVariables
โญ
0 XP
Level 1
๐Ÿ”ฅ0
Your Progress 0 / 6 steps
1
๐Ÿ“ก
Netcode Setup & Core Ideas
Install NGO and learn the three big words
Active
๐ŸŽฏ
Goal for this step

Install Netcode for GameObjects and grasp host/client/authority.

  • 1Window โ†’ Package Manager โ†’ Unity Registry โ†’ install Netcode for GameObjects (NGO), Unityโ€™s official multiplayer layer.
  • 2The three words that ARE multiplayer: Host (runs the game AND plays), Client (connects to a host), Authority (WHO is allowed to decide what is true).
  • 3Golden rule: the SERVER owns the truth. Clients REQUEST; the server DECIDES. Every cheat-proof game works this way.
  • 4Scene setup: an empty NetworkManager GameObject with the NetworkManager component + Unity Transport. That is the switchboard.
๐Ÿ‘จโ€๐Ÿ‘ง
Parent note: Everything here runs locally (two windows on one PC), no servers to rent, no accounts needed. NGO is free and built by Unity.
โœ๏ธ
Fill in the Blanks
+15 XP
A plays and serves at once, while a connects to it. Who may change a value is called , and it belongs to the server.
๐Ÿง 
Knowledge Check
+15 XP
Why must the SERVER own the truth (positions, scores, health)?
AServers are faster
BIf clients decided their own truth, any player could claim "I have 999 health", authority is anti-cheat by design
CUnity requires it
2
๐Ÿƒ
Your First Networked Player
NetworkObject, NetworkTransform, spawn on join
Locked
๐ŸŽฏ
Goal for this step

Make a player prefab that spawns and syncs for every joiner.

  • 1Player prefab: sprite + NetworkObject (its network identity) + NetworkTransform (auto-syncs position!) + movement script.
  • 2Assign it as the Default Player Prefab on the NetworkManager, NGO spawns one per connection automatically.
  • 3Movement scripts become NetworkBehaviour and gate on IsOwner, otherwise YOUR keys move EVERY player on screen (the classic first bug, try it once, on purpose!).
  • 4Add temporary UI buttons: Host / Client (NetworkManager.Singleton.StartHost / StartClient).
NetPlayerMove.cs
using Unity.Netcode;
using UnityEngine;

public class NetPlayerMove : NetworkBehaviour
{
    public float speed = 5f;

    void Update()
    {
        if (!IsOwner) return;    // only drive YOUR player!

        Vector2 input = new Vector2(
            Input.GetAxisRaw("Horizontal"),
            Input.GetAxisRaw("Vertical")).normalized;

        transform.position += (Vector3)(input * speed * Time.deltaTime);
    }
}
โŒจ๏ธ
Code Challenge
+20 XP
Stop your keys driving everyoneโ€™s character:
NetPlayerMove.cs
void Update()
{
    if (!) ;
    // ... movement ...
}
๐Ÿ’ก Hint: A NetworkBehaviour knows whether this instance belongs to the local player; bail out early when it does not.
๐Ÿง 
Knowledge Check
+15 XP
Without the IsOwner check, pressing W movesโ€ฆ
ANothing
BEVERY playerโ€™s character in your window, each copy of the script reads your keyboard
COnly the host
3
๐Ÿงช
Two Windows, One Game
Build & run alongside the editor and TEST it
Locked
๐ŸŽฏ
Goal for this step

Actually run multiplayer: a build as host, the editor as client.

  • 1Build the game (File โ†’ Build). Launch the .exe โ†’ click Host.
  • 2Press Play in the editor โ†’ click Client. Two players appear in BOTH windows.
  • 3Move in each window, watch the other update live. Feel that? That is the moment.
  • 4Under the hood: your position โ†’ serialized โ†’ sent over the transport โ†’ applied remotely, ~50 times a second, both directions.
  • 5This build+editor workflow is how you will test all networking from now on.
๐Ÿ’ก
Seeing your own game run networked for the first time is a top-five gamedev moment. Screenshot both windows. You earned it.
โœ๏ธ
Fill in the Blanks
+15 XP
The standard test loop is a running as host with the joining as client. NetworkTransform syncs position roughly times per second.
๐Ÿง 
Knowledge Check
+15 XP
Why test with a build + editor instead of two editors?
AEditors cannot connect
BOne project opens once, build+editor is the fastest honest two-instance test on one machine
CBuilds are prettier
4
๐Ÿ”ข
NetworkVariables: Shared State
A synced score that all players see
Locked
๐ŸŽฏ
Goal for this step

Share game state correctly with NetworkVariable.

  • 1Shared values live in NetworkVariable<T>, the server writes, everyone reads, sync is automatic.
  • 2A ScoreBoard NetworkBehaviour: NetworkVariable<int> score; only the server may change it (authority!).
  • 3Clients react via OnValueChanged, update the UI text when the value arrives.
  • 4Add collectable coins (server-spawned NetworkObjects): a player touching one โ†’ the SERVER destroys it and bumps score. One truth, no arguments.
ScoreBoard.cs
using Unity.Netcode;
using TMPro;

public class ScoreBoard : NetworkBehaviour
{
    public NetworkVariable<int> score = new NetworkVariable<int>(0);
    public TMP_Text label;

    public override void OnNetworkSpawn()
    {
        score.OnValueChanged += (oldVal, newVal) =>
            label.text = "Score: " + newVal;
    }

    public void AddPoint()
    {
        if (!IsServer) return;      // authority!
        score.Value += 1;
    }
}
โœ๏ธ
Fill in the Blanks
+15 XP
Synced state lives in a , which only the writes. Clients update UI through its callback.
๐Ÿง 
Knowledge Check
+15 XP
The if (!IsServer) return; guard in AddPoint enforcesโ€ฆ
AFrame rate
BServer authority, a client calling it does nothing; only the truth-owner may change the score
CFaster syncing
5
๐Ÿ“ฃ
RPCs: Making Things Happen
ServerRpc requests, ClientRpc broadcasts
Locked
๐ŸŽฏ
Goal for this step

Use RPCs for actions and effects across the network.

  • 1NetworkVariables sync STATE; RPCs (remote procedure calls) send EVENTS.
  • 2ServerRpc: a client asks the server to do something ("I pressed the emote button!"). Method name MUST end in ServerRpc.
  • 3ClientRpc: the server tells all clients to show something ("play the confetti on player 2!").
  • 4The full loop: client presses E โ†’ EmoteServerRpc() โ†’ server validates โ†’ EmoteClientRpc() โ†’ every screen shows the emote. Request up, broadcast down, that is 90% of multiplayer gameplay code.
PlayerEmote.cs
using Unity.Netcode;
using UnityEngine;

public class PlayerEmote : NetworkBehaviour
{
    void Update()
    {
        if (IsOwner && Input.GetKeyDown(KeyCode.E))
            EmoteServerRpc();
    }

    [ServerRpc]
    void EmoteServerRpc()
    {
        EmoteClientRpc();       // server approves & broadcasts
    }

    [ClientRpc]
    void EmoteClientRpc()
    {
        // runs on EVERY client:
        Instantiate(confettiPrefab, transform.position,
                    Quaternion.identity);
    }
}
โŒจ๏ธ
Code Challenge
+20 XP
Wire the request-up, broadcast-down loop:
PlayerEmote.cs
]
void EmoteServerRpc()
{
    ();
}
[  ]
void EmoteClientRpc() { /* effect */ }
๐Ÿ’ก Hint: The attribute marking a clientโ†’server call; the server then invokes the broadcast; marked with the serverโ†’clients attribute.
๐Ÿง 
Knowledge Check
+15 XP
NetworkVariable vs RPC, the right split isโ€ฆ
AThey are interchangeable
BOngoing STATE (score, health) โ†’ NetworkVariable; one-shot EVENTS (emote, explosion) โ†’ RPC
CRPCs for everything
6
๐Ÿ†
A Tiny Networked Game & Series Wrap
Coin race + everything you now know
Locked
๐ŸŽฏ
Goal for this step

Assemble a 2-player coin-race and close out the series.

  • 1Assemble the pieces: synced players โœ“ server-spawned coins โœ“ NetworkVariable scores (one per player or a simple shared board) โœ“ a win banner via ClientRpc at 10 coins โœ“.
  • 2Playtest with a friend on your LAN (same network: host shows their local IP in the transport, client enters it).
  • 3Series retrospective, you now hold: components & prefabs, physics, animation state machines, coroutines, UI/persistence, scenes, and networked authority. That is a professional Unity foundation.
  • 4The engine is yours now. Build the game only YOU would make. ๐Ÿ”ท
๐Ÿ’ก
Multiplayer ideas that fit your current skills: co-op coin race, competitive breakout (two paddles!), tag, a tiny arena shooter. Small + finished beats big + abandoned.
โœ๏ธ
Fill in the Blanks
+15 XP
Coins must be spawned by the so it owns their truth. The win announcement reaches every screen through a .
๐Ÿง 
Knowledge Check
+15 XP
Eight Unity episodes done. The deepest lesson of the multiplayer finale wasโ€ฆ
ANetworking is impossible
BAuthority: decide WHO owns each piece of truth and all of multiplayer falls into place
CRPCs are named weirdly
๐ŸŽ‰๐Ÿ†๐ŸŽฎโœจ๐ŸŽ‰
Workshop Complete!
Host, client, sync, authority, RPCs, eight episodes from Pong to networked multiplayer. You are a Unity developer, full stop. ๐Ÿ”ท๐Ÿ†
0
Total XP
1
Level
0
Best Streak
0%
Accuracy
โญ View My Progress & Certificates

This workshop was free and took many hours to build. If it helped you learn something new, consider supporting the project.

☕ Support on Ko-fi