menu_bookDocumentation
Network Ownership: Transfer, IsProxy, and Orphaned Modes
Networked GameObjects can be owned by a connection. The owner simulates the object — controlling its position and sync properties. Unowned objects are simulated by the host.
Checking Ownership with IsProxy
The most common pattern is checking IsProxy to determine if you should simulate an object:
CSHARP
protected override void OnUpdate()
{
if ( IsProxy ) return; // controlled by someone else
if ( Input.Pressed( "use" ) )
{
TryPickup();
}
}Taking Ownership
CSHARP
void TryPickup()
{
var tr = Scene.Trace.Ray( EyePos, EyePos + LookDir.Forward * 100 )
.WithoutTags( "player" )
.Run();
if ( !tr.Hit ) return;
tr.GameObject.Network.TakeOwnership();
Carrying = tr.GameObject;
}Dropping Ownership
When dropped, the object becomes owned by the server:
CSHARP
void ThrowObject()
{
if ( !Carrying.IsValid() ) return;
Carrying.Network.DropOwnership();
Carrying = null;
}Owner Transfer Modes
By default only the host can change ownership. The current owner can change this:
CSHARP
go.Network.SetOwnerTransfer( OwnerTransfer.Takeover );| Type | Behaviour |
|---|---|
| OwnerTransfer.Fixed (default) | Only the host can change the owner |
| OwnerTransfer.Takeover | Anyone can change the owner |
| OwnerTransfer.Request | A request must be made to the host |
Orphaned Mode (Disconnection)
By default, owned objects are destroyed when the owner disconnects. Change this with:
CSHARP
go.Network.SetOrphanedMode( NetworkOrphaned.Host );| Type | Behaviour |
|---|---|
| NetworkOrphaned.Destroy (default) | Object destroyed on disconnect |
| NetworkOrphaned.Host | Host takes ownership |
| NetworkOrphaned.Random | Random client takes ownership |
| NetworkOrphaned.ClearOwner | Object remains, host simulates |
Default Owners
- Scene objects: no owner by default (host simulates)
- Objects spawned via NetworkSpawn(): the spawning client is the owner
Was this helpful?