Quantcast
Channel: Photon Unity Networking (PUN) — Photon Engine
Viewing all articles
Browse latest Browse all 8947

Why cannot I destroy the player?

$
0
0
The code:

public void SetHit(float damage){
photonView.RPC("SetHitRPC",PhotonTargets.All,damage);

}

[PunRPC]
void SetHitRPC(float damage,PhotonMessageInfo info){
if(this.photonView.isMine){
Debug.Log("SetHit");

if(health > 0){
health -= damage;
mk_UIController.healthText.text = health.ToString();
}

if(health <= 0){
health = 0;
if(onDeath != null){
onDeath("Test");//info.sender.NickName
}

if(onRespawn != null){
onRespawn(5.0f);
}
Debug.Log("SetHitRPC");
StartCoroutine(DestroyPlayerCor());
}
}

}

IEnumerator DestroyPlayerCor(){
yield return new WaitForSeconds(2.0f);
Debug.Log("death");
PhotonNetwork.Destroy(gameObject);
}

Viewing all articles
Browse latest Browse all 8947