menu_bookDocumentation

NetworkSpawn, Ownership Transfer, and Network.Refresh in s&box

calendar_today May 4, 2026 schedule ~1 min read person patrickjr verified 50

NetworkSpawn and Ownership Transfer in s&box

Spawning a Networked Object

CSHARP
// Spawn with local connection as owner
go.NetworkSpawn();

// Spawn with a specific owner
go.NetworkSpawn( someConnection );

// Spawn with full options
go.NetworkSpawn( new NetworkSpawnOptions
{
    Owner = someConnection,
    StartEnabled = true,
    OrphanedMode = NetworkOrphaned.Host,
    OwnerTransfer = OwnerTransfer.Takeable,
    Flags = NetworkFlags.NoInterpolation,
    AlwaysTransmit = false
} );

Ownership Transfer Modes (OwnerTransfer)

ValueBehavior
FixedOnly the host can change ownership
TakeableAny client can take ownership freely
RequestClients must request ownership from the host

Taking and Dropping Ownership

CSHARP
// Take ownership (respects OwnerTransfer mode)
go.Network.TakeOwnership();

// Assign to a specific connection
go.Network.AssignOwnership( connection );

// Drop ownership (object becomes host-controlled)
go.Network.DropOwnership();

Checking Ownership

CSHARP
bool isOwner = go.Network.IsOwner;
bool isProxy = go.Network.IsProxy;
bool isCreator = go.Network.IsCreator;
Connection owner = go.Network.Owner; // null if unowned

Network Refresh

After making structural changes (adding/removing components or child GameObjects), call Refresh() to sync the full state to all clients:

CSHARP
go.Network.Refresh();                    // full refresh
go.Network.Refresh( someDescendant );    // refresh a specific child
go.Network.Refresh( someComponent );     // refresh a specific component

AlwaysTransmit

By default AlwaysTransmit = true. When false, the engine uses PVS (Potentially Visible Set) and bounds-based culling to skip sending updates to connections that can't see the object. Objects must be invisible for 2 seconds before culling kicks in.

Was this helpful?