Player getting duplicated when respwan

Options
Hello all , please help me as im new to the multiplayer :) ,

in the game everything works fine , but when the player is killed and respwan its getting duplicated . no errors but
getting this warning "Had to lookup view that wasn't in photonViewList: View (0)2004 on FPSPlayer(Clone) "

to destory im using

[PunRPC]
public void GetShot(float damage , string enemyName){

health -= damage;
if (health <= 0 && photonView.isMine) {


if(SendNetworkMessage != null)
SendNetworkMessage(PhotonNetwork.player.name + " was killed by " + enemyName);

if( RespawnMe != null)
{
RespawnMe(3f);
PhotonNetwork.Destroy(gameObject);
}

}



}


and calling using

hit.transform.GetComponent<PhotonView>().RPC("GetShot",PhotonTargets.All,damage , PhotonNetwork.player.name);




thanks for the time :smile:

jathoo

Comments

  • kamend
    Options
    You are probably calling the RPC from multiple clients, you have to choose which client is going to have the authority for collision hits, for example you could say the the Master Client will be responsible, in that case you will call the RPC method, only if PhotonNetwork.isMasterClient is true, the other way is to check if the attached PhotonView is your own and call the RPC.

  • jathoo
    Options
    Hello Kamend , thank you for answring , i just followed this tutorial https://unity3d.com/learn/tutorials/modules/intermediate/live-training-archive/merry-fragmas-multiplayer-fps-2 .

    and did what it says there?

    is there anything got changed?
  • TylakNF
    Options
    jathoo, another strategy is to simply not destroy the player on death. Instead, give the player a death state, then on respawn just teleport them to the spawn location and change them from death state to a living state. That eliminates the need to destroy/create anything.
  • jathoo
    Options
    thank you tylakNF , i just did that and i found out that the problem was on the tutorial code it self .