Prediction
Use prediction to manage latency in your game.
| Topic | Description |
|---|---|
| Introduction to prediction | Client prediction allows clients to use their own inputs to locally simulate the game, without waiting for the server's simulation result. |
| Prediction in Unity Netcode | Implement client prediction in Unity Netcode. |
| Prediction error smoothing | Reconcile mispredictions over time instead of snapping. One of three smoothing features, refer to Smoothing. |
| Prediction switching | Netcode supports opting into prediction on a per-client, per-ghost basis, based on some criteria (for example, predict all ghosts inside this radius of my clients' character controller). This feature is called prediction switching. |
| Prediction edge cases and known issues | When using client-side prediction, there are a few known edge cases you should be aware of. |
Smoothing
Netcode has three smoothing features that solve different problems. They're independent and can be combined.
| Feature | What it smooths | Where to enable it |
|---|---|---|
| Full tick smoothing | The frames between two full ticks, for ghosts that don't run partial ticks: every ghost on a single-world host, and predicted ghosts on clients when the NetcodeConfig Partial Tick Mode Selection is Full Ticks Only. | Per prefab, Full Tick Smoothing on the ghost authoring component. |
| Prediction error smoothing | Mispredictions: a server correction is spread over several ticks. | GhostPredictionSmoothing singleton, per component type. |
| Prediction switching smoothing | The visual jump when a ghost switches between interpolated and predicted. | ConvertPredictionEntry.TransitionDurationSeconds when queuing the switch. |