Ev Destroy Failed. Could not find PhotonView with instantiationId

Options
Hi everyone, im using PUN v 1.66 and im getting this error message in player 1(master client) when a second player has his bullet being destroyed.

The game is a gunbound style game. When I have just one player in room(unity editor), I shoot a bullet and it gets destroyed using:

In Bullet.cs
void OnCollisionEnter(Collision collision)
{
if(photonView.isMine)//PhotonNetwork.isMasterClient)
{
Debug.Log("destroying bullet: " + photonView.ownerId);
PhotonNetwork.Destroy(photonView);
}
}
This works well, no error messages. Bullet gets destroyed.

When I add a second player, and is this one (android device) who shoots, I get error message on first player(unity editor MAC OSX):

Ev Destroy Failed. Could not find PhotonView with instantiationId 2003. Sent by actorNr: 2
UnityEngine.Debug:LogError(Object)
NetworkingPeer:OnEvent(EventData) (at Assets/Photon Unity Networking/Plugins/PhotonNetwork/NetworkingPeer.cs:2013)
ExitGames.Client.Photon.PeerBase:DeserializeMessageAndCallback(Byte[])
ExitGames.Client.Photon.EnetPeer:DispatchIncomingCommands()
ExitGames.Client.Photon.PhotonPeer:DispatchIncomingCommands()
PhotonHandler:Update() (at Assets/Photon Unity Networking/Plugins/PhotonNetwork/PhotonHandler.cs:125)

So, it seams player two tries to destroy photonView while it(bullet) is already destroyed, how can I prevent this?, what does photonView.isMine means in this context?, Im new on photon pun, still getting to know how all this works. Regards,
BTW, I tried posting this question in thread:
http://forum.photonengine.com/discussion/comment/28113/#Comment_28113
as it was related, but got no answers, so Im doing it here.

Comments

  • vadim
    Options
    Hi,

    New post is better option. Keep discussion here please. I already answered in other topic. Duplicating:

    Make sure that you destroy object only once and do this with PhotonNetwork.Destroy from object owner client.
    The error may arise if you do so with Unity's Destroy in some other place.
    IsMine check guarantees that PhotonNetwork.Destroy is called from object owner.
  • agarrote
    Options
    Hi vadim,
    What Im trying to do, is destroy bullets shot by players as it collides with anything. So, bullets ARE GETTING DESTROYED, both on local and on remote clients. But error message arise on Unity editor:
    Ev Destroy Failed. Could not find PhotonView with instantiationId 2003. Sent by actorNr: 2 ...

    Ah, only owners have bullets with rigidBody component attached, remote clients dont attach rigidBody to synced bullets.

    Since, bullets are getting destroyed in:

    void OnCollisionEnter(Collision collision)
    { if(photonView.isMine)//PhotonNetwork.isMasterClient)
    PhotonNetwork.Destroy(photonView);
    }

    Could this be the problem?,
  • jeanfabre
    jeanfabre mod
    edited May 2016
    Options
    Hi,

    Have you tried with the following version? PhotonNetwork.Destroy(gameObject);

    Bye,

    Jean