Networked Objects: Spawning, Network Modes, and Interpolation
Any GameObject can become networked by calling NetworkSpawn(). It will then be sent to all clients and can have Sync Properties and RPC Messages.
Spawning a Networked Object
var go = new GameObject();
go.NetworkSpawn();Every networked object can have an owner who controls its position, rotation, scale, and sync properties.
Network Modes
| Mode | Behaviour |
|---|---|
| NetworkMode.Never | Never networked to others |
| NetworkMode.Object | Sent as its own networked object with sync properties and RPCs |
| NetworkMode.Snapshot (default) | Host sends this as part of the initial scene snapshot when a client joins |
Interpolation
Transform of all networked objects is interpolated smoothly for other clients by default.
Disabling Interpolation
Network.DisableInterpolation();Clearing Interpolation (Teleporting)
Transform.Position = Vector3.Zero;
Network.ClearInterpolation();When the owner clears interpolation, other clients will update position immediately without smoothing on the next transform update.
Refreshing a Networked Object
After calling NetworkSpawn(), further changes to components or hierarchy are NOT automatically networked. Only the state at spawn time is sent.
If you add new components, change enabled state, add children, or modify hierarchy, call Network.Refresh() to send an update:
// After adding a new component post-spawn
gameObject.Components.Create<MyNewComponent>();
gameObject.Network.Refresh();By default only the host can send refresh updates. Enable owner refresh via connection permissions.