Correct Way to Network Delete Scene Object

Options
Hi,

I have an object named objParent which is PhotonNetwork.Instantiated using a script associated with a button that is pressed during a runtime session. I have another button and script that I want to use to destroy the objParent. I have tried using PhotonNetwork.Destroy(objParent); but keep getting this error - Failed to 'network-remove' GameObject because it's null. I am unsure what I am doing wrong.

PhotonView says the following:
ViewID 1001
IsMine: True (master)
Controller: [1] (master)
Owner: [1] (master)
Creator: [1] (master)

If I am using the wrong method, can someone suggest an alternative to network destroy the object fo all users.

Many Thanks

Comments

  • Tobias
    Options
    It sounds as if some other code already did a GameObject.Destroy on said object.
    Unity sometimes has the C# object still around unless you check for Null. This can be confusing.

    To debug this, I would use a script that logs when it gets destroyed. This way, you can see who is calling Destroy on the object (and if there are multiple such calls).