OpRemoveFromServerInstantiationsOfPlayer
How do I use Op Remove From Server Instantiations Of Player
Below are practical examples compiled from projects for learning and reference purposes
Featured Snippets
Line | Code | Ex.. |
---|---|---|
2441 | this.OpRemoveFromServerInstantiationsOfPlayer(playerId); | 1 |
2634 | private void OpRemoveFromServerInstantiationsOfPlayer(int actorNr) | 2 |
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
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
2634 private void OpRemoveFromServerInstantiationsOfPlayer(int actorNr)
2635 {
2636 // removes all "Instantiation" events of player actorNr. this is not an event for anyone else
2637 RaiseEventOptions options = new RaiseEventOptions() { CachingOption = EventCaching.RemoveFromRoomCache, TargetActors = new int[] { actorNr } };
2638 this.OpRaiseEvent(PunEvent.Instantiation, null, true, options);
2639 //this.OpRaiseEvent(PunEvent.Instantiation, null, true, 0, new int[] { actorNr }, EventCaching.RemoveFromRoomCache);
2640 }
OpRemoveFromServerInstantiationsOfPlayer 132 lượt xem
Gõ tìm kiếm nhanh...