The Photon Forum
is Closed Permanently.

After many dedicated years of service, we have made the decision to retire our Forum and switch to read-only: we´ve saved the best to last! Your search result can be found below. Plus, we offer support via these channels:

Try Our
Documentation

Please check if you can find an answer in our extensive documentation on PUN.

Join Us
on Discord

Meet and talk to our staff and the entire Photon-Community via Discord.

Read More on
Stack Overflow

Find more information on Stack Overflow (for Circle members only).

Write Us
an E-Mail

Feel free to send your question directly to our developers.

Ev Destroy Failed. Could not find PhotonView with instantiationId

agarrote
2016-05-11 16:39:09

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
2016-05-13 07:46:19

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
2016-05-13 20:34:15

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
2016-05-16 12:09:32

Hi,

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

Bye,

Jean

Back to top