Hello, I’m trying to make an RPC command to take away health.
here is the code
if (Physics.Raycast(transform.position, transform.forward, hit)){
if (hit.transform.tag == "players"){ //
if(GetComponent(NetworkView).networkView.isMine){
var hitID : NetworkView = hit.transform.GetComponent(NetworkView);
Debug.Log("You hit a player id:" + hitID.viewID);
hitID.RPC("ChangeHp", RPCMode.All,hitID.viewID,10);
}
}
}
}
@RPC
function ChangeHp(targetID : NetworkViewID , AmountDamage : float)
{
currentHealth -= AmountDamage;
}
and here is the error that I’m getting
“Sending RPC failed because ‘ChangeHp’ parameter 0 didn’t match the RPC declaration. Expected ‘System.Int32’ but got ‘UnityEngine.NetworkViewID’
UnityEngine.NetworkView:RPC(String, RPCMode, Object)
raycasting:Shoot() (at Assets/raycasting.js:43)”
it is giving me this error right here -
hitID.RPC(“ChangeHp”, RPCMode.All,hitID.viewID,10);
What am I doing wrong?