0
0
Unityframework~8 mins

Unity Netcode overview - Performance & Optimization

Choose your learning style9 modes available
Performance: Unity Netcode overview
HIGH IMPACT
This affects networked game performance, including latency, bandwidth usage, and frame update smoothness.
Synchronizing player position across clients
Unity
void Update() {
  if (Time.time - lastSendTime > 0.1f) {
    SendPositionToServer(transform.position);
    lastSendTime = Time.time;
  }
}

void SendPositionToServer(Vector3 pos) {
  // Sends position updates throttled to 10 times per second
  NetworkManager.Singleton.CustomMessagingManager.SendNamedMessage("UpdatePos", serverClientId, pos);
}
Throttling position updates reduces network traffic and CPU load, improving responsiveness.
📈 Performance GainReduces network messages by ~90%, lowering latency and CPU usage
Synchronizing player position across clients
Unity
void Update() {
  SendPositionToServer(transform.position);
}

void SendPositionToServer(Vector3 pos) {
  // Sends position every frame without throttling
  NetworkManager.Singleton.CustomMessagingManager.SendNamedMessage("UpdatePos", serverClientId, pos);
}
Sending position updates every frame floods the network with messages, causing high bandwidth use and latency.
📉 Performance CostTriggers high network traffic, increasing latency and CPU load on clients and server
Performance Comparison
PatternNetwork MessagesCPU LoadLatency ImpactVerdict
Send every frameHigh (60+ per second)HighHigh latency and jitter[X] Bad
Throttled updatesLow (10 per second)LowLow latency, smooth gameplay[OK] Good
Rendering Pipeline
Network messages are serialized and sent over the network, then deserialized and applied to game objects, triggering updates in the rendering pipeline.
Network Serialization
Game Logic Update
Rendering
⚠️ BottleneckNetwork Serialization and Deserialization
Optimization Tips
1Throttle network messages to avoid flooding the network.
2Send only changed data (deltas) instead of full states.
3Use efficient serialization to reduce CPU load.
Performance Quiz - 3 Questions
Test your performance knowledge
What is a main performance issue when sending network updates every frame in Unity Netcode?
AExcessive network traffic causing latency
BToo few messages causing desync
CRendering pipeline stalls
DMemory leaks in game objects
DevTools: Network Profiler
How to check: Open Unity Profiler, select Network section, run game and observe message frequency and size.
What to look for: Look for high message counts or large payloads causing spikes in network usage and CPU load.