public void BindToClient(NetworkClient client) { client.RegisterHandler(MsgTypeExt.STATE_UPDATE, HandleStateUpdate); //perform custom ownership system (client) client.RegisterHandler(MsgTypeExt.OWNERSHIP, (msg) => { //-1 means local client "ownership" Ownerships.RegisterOwnership(-1, ClientScene.FindLocalObject(new NetworkInstanceId(msg.ReadMessage <UintMsgBase>().val))); }); this.client = client; }
/// <summary> /// Spawns a GameObject on all clients and registers its ownership /// /// </summary> /// <param name="ownerId">The owner connection id</param> /// <param name="obj">The object to spawn and register</param> public void Spawn(int ownerId, GameObject obj) { NetworkServer.Spawn(obj); Ownerships.RegisterOwnership(ownerId, obj); NetworkServer.connections[ownerId].SendByChannel(MsgTypeExt.OWNERSHIP, new UintMsgBase(obj.GetComponent <NetworkIdentity>().netId.Value), Channels.DefaultReliable); }