Ok so I have bin programing a multiplayer TPS (expected FPS did we?), and everything has bin going pretty
good so far. But now I am at a part of my multiplayer code where I keep getting the same error that makes
no sense to me;
Sending RPC failed because ‘ApplyDamage’ parameter 0 didn’t match the RPC declaration. Expected ‘System.Object’ but got ‘System.Single’
UnityEngine.NetworkView:RPC(String, RPCMode, Object[ ])
shooter:Fire() (at Assets/scripts/shooter.js:65)
shooter:Update() (at Assets/scripts/shooter.js:40)
Now in my mind this should be simple, do a raycast (bullet if you will) and send a RPC to the player I hit;
hit.transform.gameObject.networkView.RPC("ApplyDamage", RPCMode.All, damage);
Thus calling;
@RPC
function ApplyDamage(damage){
health -= damage;
if(health <= 0.0)
Die();
}
But it never calls “ApplyDamage” because “‘ApplyDamage’ parameter 0 didn’t match the RPC declaration”.
So can someone please tell me what I am doing wrong here? Or maybe give a link to somewhere that can help me out?