Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Photon.Network Destroy Object

Discussion in 'Scripting' started by Chris11, Oct 12, 2014.

  1. Chris11

    Chris11

    Joined:
    Sep 26, 2014
    Posts:
    9
    hey

    i have an Object " M4A1 " and i instantiate it with :

    Code (CSharp):
    1. void Start () {
    2.         GameObject m4 = (GameObject)PhotonNetwork.Instantiate("M4A1 PickUp", new Vector3(0,0,0), new Quaternion(0,0,0,0), 0);
    3.     }
    when i pick it up i wanna destroy the Object:
    Code (CSharp):
    1. [RPC]
    2.     void OnTriggerStay(Collider other) {
    3.        
    4.         if(Input.GetButtonDown("Interaction")){
    5.             TakeItem ();
    6.             DestroyOnNetwork (other);
    7.         }
    8.     }
    the destroyonnetwork function:

    Code (CSharp):
    1. void DestroyOnNetwork(Collider other) {
    2.  
    3.         PhotonNetwork.Destroy(other.gameObject);
    4.  
    5.         if( GetComponent<PhotonView>().instantiationId==0 ) {
    6.             Destroy(other.gameObject);
    7.         }
    8.         else {
    9.             if( GetComponent<PhotonView>().isMine ) {
    10.                 PhotonNetwork.Destroy(other.gameObject);
    11.             }
    12.         }
    13.     }


    My Problem is that i can only destroy the object with the master client.

    other clients get the error:

    Failed to 'network-remove' GameObject. Client is neither owner nor masterClient taking over for owner who left: View (0)1002 on M4A1 PickUp(Clone)

    how can i destroy the object if iam not the master client ? i thought the [RPC] over void OnTriggerStay(Collider other) would do that part for me ?
     
  2. Chris11

    Chris11

    Joined:
    Sep 26, 2014
    Posts:
    9
    help please i cant seem to find a solution
     
  3. ndru-pi-squared

    ndru-pi-squared

    Joined:
    Jan 26, 2019
    Posts:
    1
    Did you ever find a solution?
     
  4. ElSabadero

    ElSabadero

    Joined:
    Dec 7, 2018
    Posts:
    7
    PhotonNetwork.Destroy()
     
  5. Ikee_0521

    Ikee_0521

    Joined:
    Jan 15, 2020
    Posts:
    4
    Any Solution for this? having the same problem...