Destroying a gameobject which is instanced as 'Manual Instanced'

We have a complex system where we need to instantiate some items with RaiseEvents (Manual Instantiation), since we don't use the PhotonNetwork.Instantiate with some resources prefabs we cannot use PhotonNetwork.Destroy method.

Is there a way to destroy it in the 'rightway' manually to avoid this error?
Failed to 'network-remove' GameObject. Client is neither owner nor MasterClient taking over for owner who left: View 2003 on Cube 
UnityEngine.Debug:LogError(Object)
etc
This is happens when we trying to destroy it. We also set owner of the gameobject in runtime. Updating transferownership.

Right now we just set objects to .SetActive(false) to fake it. But it feels like having tons of objects with PhotonView set to false in background is a bit of waste.
Thanks /Tobias

Comments

  • JohnTube
    JohnTube ✭✭✭✭✭
    Hi @Lostsomfan,

    Thank you for choosing Photon!

    The error is not due to the fact that you are doing manual instantiation.
    It's more about the fact that the client who tries to network destroy the manually instantiated network object is not allowed to do so (has no authority over this object: client is not creator, nor owner, nor controller).
    So you need to make sure to destroy those objects either from the controller (photonView.IsMine needs to be true).

    Otherwise, feel free to add your own manual network destroy logic by reverting what you do in the manual network instantiation: remove cached event, send custom network destroy event (to others (A) / all (B)), destroy object locally first (A) or wait for event to destroy (B).
  • Lostsomfan
    edited December 2020
    Thanks for @JohnTube for the answer!
    When we read your post we noticed we stop caring about basic, essential Photon logics. PV.IsMine is a classic good reminder to use! ;) We sorted it by checking local Item lists with actor numbers and checked if current item belonged to me or others. Everything fell together smoothly!