Destroy inactive actors' gameobjects instantiated by PhotonNetowrk.Instantiate()

By following this FAQ and using OpRejoin(), I can now have player rejoin when they reconnect[/url].

However, there is a photonview duplicate id issue. I am instantiating some game objects using PhotonNetowrk.Instantiate() on the client. When player disconnects and their actor becomes inactive, these game objects don't get destroyed. When the a player rejoins the room, player tries to instantiate game object again then gets this error "PhotonView ID duplicate found". I am considering destroying these game objects when player's actor becomes inactive.

- Is there a way to destroy gameobjects when a player gets disconnected and become an inactive actor?
- Is there any suggestions to handle this in a different way?

Thanks

Comments

  • TobiasTobias admin
    Which version of PUN did you use? If it's not the latest PUN 2, please update, then report if the problem persists.

    > Is there a way to destroy gameobjects when a player gets disconnected and become an inactive actor?

    Yes, you can do that via PhotonNetwork.DestroyPlayerObjects(Player targetPlayer).

    Keep in mind that you need to set RoomOptions.PlayerTTL to use ReconnectAndRejoin properly. With ReconnectAndRejoin, the leaving player should clean up objects and on rejoin will re-create them.
Sign In or Register to comment.