menu_bookDocumentation
IGameObjectNetworkEvents: StartControl, StopControl, and NetworkOwnerChanged Callbacks
IGameObjectNetworkEvents: Ownership Change Callbacks
Implement IGameObjectNetworkEvents on a component to receive callbacks when network ownership of the parent GameObject changes.
Interface Methods
CSHARP
public interface IGameObjectNetworkEvents : ISceneEvent<IGameObjectNetworkEvents>
{
// Called when the owner changes (any direction)
void NetworkOwnerChanged( Connection newOwner, Connection previousOwner ) { }
// We have become the controller — no longer a proxy
void StartControl() { }
// We have become a proxy — someone else controls this
void StopControl() { }
}Usage
CSHARP
public class MyComponent : Component, IGameObjectNetworkEvents
{
void IGameObjectNetworkEvents.StartControl()
{
// We now own this object — enable local simulation
Log.Info( "I am now in control" );
}
void IGameObjectNetworkEvents.StopControl()
{
// We lost control — disable local simulation
Log.Info( "I am now a proxy" );
}
void IGameObjectNetworkEvents.NetworkOwnerChanged( Connection newOwner, Connection previousOwner )
{
Log.Info( $"Owner changed from {previousOwner?.DisplayName} to {newOwner?.DisplayName}" );
}
}When StartControl / StopControl Fire
- StartControl fires when Owner changes to Connection.Local.Id, or when the object becomes unowned and we are the host.
- StopControl fires when we lose ownership.
- Transform interpolation is cleared when ownership changes.
IsProxy
Component.IsProxy (and GameObject.IsProxy) returns true when the local client does not own the object. Use this to skip local simulation on proxies.
Was this helpful?