0
0
Unityframework~10 mins

Unity Netcode overview - Step-by-Step Execution

Choose your learning style9 modes available
Concept Flow - Unity Netcode overview
Start: Game Launch
Initialize Network Manager
Choose Role: Host / Client
Host: Start Server
Synchronize Game State
Send/Receive Network Messages
Update Game Objects Across Network
Gameplay
End or Disconnect
This flow shows how Unity Netcode starts with initializing the network, choosing host or client roles, connecting, syncing game state, and updating objects during gameplay.
Execution Sample
Unity
NetworkManager.Singleton.StartHost();
// Host starts server and client

NetworkManager.Singleton.StartClient();
// Client connects to server

// Networked objects sync automatically
This code starts a host or client in Unity Netcode, enabling networked gameplay with automatic synchronization.
Execution Table
StepActionNetworkManager StateResult
1Call StartHost()IsHost = false, IsClient = falseStarts server and client, IsHost = true, IsClient = true
2Host waits for clientsIsHost = true, IsClient = trueServer ready, waiting for clients to connect
3Call StartClient() on clientIsHost = false, IsClient = falseClient connects to server, IsClient = true
4Server and client synchronizeIsHost = true, IsClient = true (host), IsClient = true (client)Game state synced across network
5Networked objects updateObjects have NetworkObject componentObjects' states replicate on all clients
6Gameplay continuesNetworkManager runningPlayers interact with synced game world
7Disconnect or stopNetworkManager activeNetwork session ends, cleanup happens
💡 Execution stops when the network session ends or game closes.
Variable Tracker
VariableStartAfter Step 1After Step 3After Step 4Final
IsHostfalsetruefalsefalsefalse (after disconnect)
IsClientfalsetruetruetruefalse (after disconnect)
Network Objects SyncedNoNoNoYesNo (after disconnect)
Key Moments - 3 Insights
Why does the host have both IsHost and IsClient true?
Because the host runs both server and client in one instance, as shown in execution_table step 1.
How do networked objects update on all players?
Objects with NetworkObject component automatically sync their state across clients, as in step 5.
What happens if a client disconnects?
The network session cleans up and stops syncing for that client, shown in the exit_note and final variable states.
Visual Quiz - 3 Questions
Test your understanding
Look at the execution_table, what is the NetworkManager state after calling StartHost()?
AIsHost = false, IsClient = true
BIsHost = true, IsClient = true
CIsHost = true, IsClient = false
DIsHost = false, IsClient = false
💡 Hint
Check execution_table row 1 under NetworkManager State.
At which step do networked objects start syncing their state?
AStep 5
BStep 4
CStep 3
DStep 6
💡 Hint
Look at execution_table row 5 describing object updates.
If the client never calls StartClient(), what happens to IsClient variable in variable_tracker?
AIt toggles between true and false
BIt becomes true anyway
CIt stays false
DIt causes an error
💡 Hint
Refer to variable_tracker row for IsClient and step 3 in execution_table.
Concept Snapshot
Unity Netcode overview:
- Use NetworkManager to start Host or Client
- Host runs server and client together
- Clients connect to Host server
- NetworkObjects sync state automatically
- NetworkManager manages connection lifecycle
- Gameplay updates sync across network
Full Transcript
Unity Netcode starts by initializing the NetworkManager. The game chooses a role: host or client. The host starts both server and client, setting IsHost and IsClient to true. Clients connect to the host by calling StartClient, setting IsClient to true. The server and clients synchronize game state automatically through NetworkObjects. During gameplay, all networked objects update their state across all players. When the session ends or a player disconnects, the network cleans up and stops syncing. This flow ensures smooth multiplayer gameplay with automatic state synchronization.