- Home /
This is giving an error for the other client and cannot hit other client.
My arrow is instantiated on a different script and has this scripts on it but when the arrow is going to get destroyed it gives Ev Destroy Failed. Could not find PhotonView with instantiationId 2002. Sent by actorNr: 2 error. I don't know what to do please help.
using UnityEngine;
using System.Collections;
public class Arrow : MonoBehaviour {
[PunRPC]
void OnCollisionEnter(Collision col){
if (col.gameObject.tag == "Player") {
col.gameObject.GetComponent<Health> ().Die ();
Debug.Log ("CleaningClutter");
if (GetComponent<PhotonView> ().instantiationId == 0) {
Destroy (gameObject);
} else {
if (GetComponent<PhotonView> ().isMine == true) {
PhotonNetwork.Destroy (gameObject);
}
}
}
Debug.Log ("CleaningClutter");
if (GetComponent<PhotonView> ().instantiationId == 0) {
Destroy (gameObject);
} else {
if (GetComponent<PhotonView> ().isMine == true) {
PhotonNetwork.Destroy (gameObject);
}
}
Debug.Log ("CleaningClutter");
}
}
code
Since void OnCollisionEnter(Collision col)
is exactly the same as the Unity physics callback, it maybe gets called twice and is already destroyed when the second call is executed. Or did you just forget to remove [PunRPC]? Is it actually called by RPC? Please check on this.
Answer by James2Games · Jun 05, 2019 at 04:09 AM
This is an old post but I had to do a bit of digging to find an answer for this.
I was able to solve this by making sure
PhotonNetwork.Destroy(gameObject);
Was not being called more than once.
Turned out my Bullets were colliding with more than one object and triggering it twice.
Your answer
Follow this Question
Related Questions
Photon wont sync for the masterclient. 1 Answer
Switching weapons in PhotonNetwork 1 Answer
Photon Network instantiate problem when Master changes 0 Answers
Photon Unity Networking Score Issue 1 Answer
Chat system is not working 1 Answer