Monster death which PhotonTarget for RPC?

Options
Hey there,
i'm wondering about which photon targets i should use for an rpc. The healthpoints of the monsters are checked every frame and if are <= 0 then the RPC get's called and the monster get's destroyed.

Which PhotonTarget selection should i use? All, AllBuffered or AllBufferedViaServer?
Should i destroy it or photon.destroy it? When i photon.destroy it, i get an error on the other clients that this photonView does'nt exist anymore for sure.

Which way do you reccomend?

:)

RPC Call:

void CheckHp() // Called from void Update
{
if (curHp <= -0.1 && hpSet == true)
{
pv.RPC("DestroyEnemy", PhotonTargets.AllBufferedViaServer);
}
}


RPC:

[PunRPC]
void DestroyEnemy()
{
Destroy(gameObject); // destroys this enemy
}


This is the version i'm using. Getting some trouble with new joined players (the enemy is still alive and bugging arround somewhere).

Ty :)

Comments

  • Hi JannickL,

    if the monster is a scene object the MasterClient can destroy it using PhotonNetwork.Destroy(...) without calling a RPC. This way all clients, who are joining later (after the monster has been defeated) will automatically destroy the game object, too.

    Please let us know if this helps you otherwise we need to find another solution for you.
  • jeanfabre
    Options
    Hi,

    you should use PhotonTarget.All you don't want to buffer it because new players joining won't be interested in knowing who died earlier on. and you don't need via Server if you do't use OnPremise and server-side Plugins.

    Bye,

    Jean