Network Object Manager
The plNetworkObjectManager handles server-authoritative spawning and despawning of prefabs across the network. It tracks ownership, authority, and provides object pooling for frequently spawned objects.
Overview
In a multiplayer game, the server decides when and where objects appear. The Object Manager:
Registers prefabs that can be spawned over the network.
Spawns prefab instances on the server and automatically replicates the spawn to all clients.
Tracks ownership and authority for each spawned object.
Despawns objects on the server and replicates the despawn to all clients.
Synchronizes existing objects to late-joining clients.
Pools objects for efficient reuse.
Accessing the Manager
Prefab Registration
Before a prefab can be spawned, it must be registered:
Unregister when no longer needed:
Check if a prefab is registered:
Spawning Objects
Spawn a networked object on the server. The spawn is automatically replicated to all clients:
Spawn as a child of another object:
The returned uiNetID is the unique network identifier for the spawned object, consistent across all machines.
Despawning Objects
Despawn all objects owned by a specific client (useful on disconnect):
Ownership and Authority
Transfer Ownership
Change Authority
Query Ownership
Object Pooling
For frequently spawned and despawned objects (projectiles, effects), enable pooling to avoid instantiation overhead:
When pooling is enabled:
SpawnNetworkObject()reuses a pooled instance instead of creating a new one.DespawnNetworkObject()deactivates and returns the object to the pool instead of destroying it.
Query pool state:
Object Lookup
Spawn Messages
Spawn lifecycle events are delivered as plMessage types to all registered plNetworkComponent subclasses, following the same pattern as session and level events. Override the handlers in your component.
Spawn Validation
Before a server-side spawn is executed, a plMsgNetworkValidateSpawn is broadcast. Any handler can reject the spawn by setting m_bAllowSpawn = false. Because SendMessage is synchronous, the result is available immediately -- if any component rejects, the spawn is cancelled and no network traffic is sent:
Post-Spawn Notification
After an object is spawned (on both server and clients receiving replicated spawns), a plMsgNetworkObjectSpawned is broadcast with the newly created game object:
Late-Joiner Synchronization
When a new client connects, call SyncAllObjectsToClient() to send the full state of all existing objects:
This is handled automatically by the plNetworkWorldModule during the handshake process.
plNetworkObjectInfo
Each tracked object has associated metadata:
Field | Type | Description |
|---|---|---|
|
| Unique network identifier |
|
| Handle to the game object |
|
| Client that owns this object |
|
| Authority level |
|
| Prefab used to spawn |
|
| When the object was spawned |
|
| Marked for destruction |
See Also
Spawning Objects Tutorial