- Home /
How to solve RPC error
class FPSPlayerNode
{
var playerName : String;
var networkPlayer : NetworkPlayer;
var score : int = 0;
}
networkView.RPC("ApplyGlobalScore", RPCMode.AllBuffered, score);
@RPC
function ApplyGlobalScore(newscore : int)
{
var entry : FPSPlayerNode = new FPSPlayerNode();
//entry.playerName = playerName;
entry.score = parseInt (newscore);
print("score:" + newscore);
}
Sending RPC failed because 'ApplyGlobalScore' parameter 0 didn't match the RPC declaration. Expected 'System.Int32' but got 'System.MonoType' UnityEngine.NetworkView:RPC(String, RPCMode, Object[]) GameSetup:Awake() (at Assets/Scripts/Scripts/GameSetup.js:38)
Hello. I got this error and i would appreciate anyone can tell me what wrong??
Answer by Dreamside · Jan 15, 2012 at 05:30 PM
you are making mistake while sending the score in networkview.RPC. you should probably make an instance of class FPSPlayerNode like FPSPlayerNode abc=new FPSPlayerNode();
abc.score =15; then send it via RPC. by the way if you want to reach score attribute directly you should make it public
i have created the FPSPlayerNode abc=new FPSPlayerNode(); var entry : FPSPlayerNode = new FPSPlayerNode(); entry.score = parseInt (newscore);
So you trying to say the
networkView.RPC("ApplyGlobalScore", RPC$$anonymous$$ode.AllBuffered, entry.score);
but it doesn't work properly. It is not updating the score display on the screen. I am using the unity $$anonymous$$2H networking example 4. The score is not being update properly.
Your answer
![](https://koobas.hobune.stream/wayback/20220613063015im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
networkview.RPC not accessible in unity 5.4 1 Answer
game objects and meshes not appearing 1 Answer
Get NetworkPlayer from ViewID 1 Answer
Photon - How to name a player? 0 Answers
Client can't serialize to client 1 Answer