Question by
Wesley21spelde · Jan 17, 2016 at 02:46 PM ·
programmingfailureadjusthealth
fixing rpc
Hey guys somthing is still wrong in this rpc
when the enemy is hit it should send an rpc to all clients to addjust its current health but is does not it still says .
NotImplementedException: The requested feature is not implemented.
i also tried this. thats matching the parameters right????.
RPC("AddjustCurrentHealth", RPCMode.All, (int adj, int curHealth);
using UnityEngine;
using System.Collections;
using System;
public class EnemyHealth : MonoBehaviour
{
public int maxHealth = 100;
public int curHealth = 10;
void OnCollisionEnter(Collision col)
{
if (col.transform.tag == "Bullet")
{
PhotonView photonView = PhotonView.Get(this);
photonView.RPC("AddjustCurrentHealth", RPCMode.All, curHealth);
}
}
[PunRPC]
public void AddjustCurrentHealth(int adj)
{
PhotonView photonView = PhotonView.Get(this);
photonView.RPC("AddjustCurrentHealth", RPCMode.All, curHealth);
curHealth += adj;
if (curHealth < 0)
curHealth = 0;
if (curHealth > maxHealth)
curHealth = maxHealth;
if (maxHealth < 1)
maxHealth = 1;
if (curHealth < 10)
Die();
}
[PunRPC]
void Die()
{
PhotonView.Destroy(gameObject);
}
}
Comment