SendDestroyOfPlayer









How do I use Send Destroy Of Player
Below are practical examples compiled from projects for learning and reference purposes

Featured Snippets


File name: NetworkingPeer.cs Copy
2430     public void DestroyPlayerObjects(int playerId, bool localOnly)
2431     {
2432         if (playerId <= 0)
2433         {
2434             Debug.LogError("Failed to Destroy objects of playerId: " + playerId);
2435             return;
2436         }
2437
2438         if (!localOnly)
2439         {
2440             // clean server's Instantiate and RPC buffers
2441             this.OpRemoveFromServerInstantiationsOfPlayer(playerId);
2442             this.OpCleanRpcBuffer(playerId);
2443
2444             // send Destroy(player) to anyone else
2445             this.SendDestroyOfPlayer(playerId);
2446         }
2447
2448         // locally cleaning up that player's objects
2449         HashSet playersGameObjects = new HashSet();
2450         foreach (PhotonView view in this.photonViewList.Values)
2451         {
2452             if (view.CreatorActorNr == playerId)
2453             {
2454                 playersGameObjects.Add(view.gameObject);
2455             }
2456         }
2457
2458         // any non-local work is already done, so with the list of that player's objects, we can clean up (locally only)
2459         foreach (GameObject gameObject in playersGameObjects)
2460         {
2461             this.RemoveInstantiatedGO(gameObject, true);
2462         }
2463
2464         // with ownership transfer, some objects might lose their owner.
2465         // in that case, the creator becomes the owner again. every client can apply this. done below.
2466         foreach (PhotonView view in this.photonViewList.Values)
2467         {
2468             if (view.ownerId == playerId)
2469             {
2470                 view.ownerId = view.CreatorActorNr;
2471                 //Debug.Log("Creator is: " + view.ownerId);
2472             }
2473         }
2474     }
File name: NetworkingPeer.cs Copy
2615     private void SendDestroyOfPlayer(int actorNr)
2616     {
2617         Hashtable evData = new Hashtable();
2618         evData[(byte)0] = actorNr;
2619
2620         this.OpRaiseEvent(PunEvent.DestroyPlayer, evData, true, null);
2621         //this.OpRaiseEvent(PunEvent.DestroyPlayer, evData, true, 0, EventCaching.DoNotCache, ReceiverGroup.Others);
2622     }

SendDestroyOfPlayer 127 lượt xem

Gõ tìm kiếm nhanh...