[PhotonEngine] Please Help : Ev Destroy Failed. Could not find PhotonView with instantiationId 2100.

Im currently facing an issue in my project, Destroying enemys and bullets! I tough this would be so simple, but im stuck with this error for weeks!

So my game consistis in a portal defense, where enemys are spawned as SceneObjects and go towards the portal, the problem is trying to destroy them as clients creates a lot of errors and lot of lag for the client, while the MasterClient faces no lag, but usualy sees frozen bullets and enemys!

Here's a demo of what happens! The PC is master client and the Android is an client!


A bunch of errors like this pop up
"Ev Destroy Failed. Could not find PhotonView with instantiationId 2100. Sent by actorNr: 2"
and more than one with the same instantiation ID

This is what the android side sees, a bunch of enemys and bullets "frozen"

This is the code used on the bullets:

 void DesativarDestruir()
    {
        Debug.Log("Bala de id: "+GetComponent<PhotonView>().InstantiationId + ", Sendo destruida");

        if (GetComponent<PhotonView>().IsMine)
            PhotonNetwork.Destroy(gameObject);
        else
            Destroy(this.gameObject);
    }

    private void OnTriggerEnter2D(Collider2D collision)
    {
        if (collision.gameObject.CompareTag("cima") || collision.gameObject.CompareTag("baixo") || collision.gameObject.CompareTag("direita") || collision.gameObject.CompareTag("esquerda"))
            SpawnarWallhit();

        if (collision.gameObject.CompareTag("boss") || collision.gameObject.CompareTag("miniboss"))
            SpawnarWallhit();

        if (collision.gameObject.CompareTag("virusPortal"))
        {
            if (isOnline)
            {
                if (!isFireBall)
                {
                    DesativarDestruir();
                }
            }
        }
    }

    void SpawnarWallhit()
    {
        if (!isFireBall)
        {
            Instantiate(WallHit, transform.position, Quaternion.Euler(0.0f, 0.0f, Random.Range(0.0f, 360.0f)));

            if (isOnline)
            {
                if (!isFireBall)
                    DesativarDestruir();
            }
            else
            {
                Destroy(this.gameObject);
            }
        }
    }

And this is on the Enemys:

void DesativarDestruir()
    {
        if (GetComponent<PhotonView>().IsMine)
            PhotonNetwork.Destroy(gameObject);
        else
            Destroy(this.gameObject);
    }


private void OnTriggerEnter2D(Collider2D collision)
    {

if (collision.gameObject.CompareTag("Bullet"))
        {
            GameObject p = Instantiate(particulaTiro, transform.position, Quaternion.identity);
            Destroy(p, 0.8f);
            TocarSomMorte();

            if (isOnline)
            {
                ExitGames.Client.Photon.Hashtable PropriedadesPlayer = new ExitGames.Client.Photon.Hashtable();
                Player player = collision.gameObject.GetComponent<PhotonView>().Owner;

                if (player != null)
                {
                    PropriedadesPlayer.Add("kills", ((int)player.CustomProperties["kills"] + 1));
                    player.SetCustomProperties(PropriedadesPlayer);
                }

                DesativarDestruir();
            }
            else
            {
                HordasStats.qtdKills++;

                Destroy(collision.gameObject);
                Destroy(this.gameObject);
            }
        }
}
1 Like

Hi,

I would also double check that none of your non master clients are destroying bullets using Unity. Bullets triggers should only work on the master, or if you want to remove bullets on clients, simply hide them, but let the masterclienbt or who ever owns the bullet to destroy it himself.

basically, the rule is that who ever creates a network object is responsible for destroying it, only the masterclient can do that for any other clients. So a client must never destroy a network object it doesn’t own.
Bye,

Jean

Hmm I’ll double check on that. And on that rule u mentioned, wont checking if PhotonNetwork.IsMine guarantee that I’m destroyin the enemy/bullet from the owner of that object? because thats what I learned from other threads, but it doesn’t seem to work with me, can’t quite figure it out why.

Hi,

well yes, but something might be wrong in your logic handling and if you have for example some childs on your network object with colliders and they are the one colliding, then you'll be destroying the wrong object. There can so many ways it can go wrong...

so I suggest you triple check all your logic with proper debugging, either via the debugger or via logs. If you still can't figure it out, you'll have to cut it down, make a copy of the project and try to repro with a minimal set by removing feature one after the other until it works again. Or you start a fresh project and try to do the minimal repro case, which would let you know if indeed there is an issue with pun or not in which case get back to us.

Let me know how it goes.

Bye,

Jean