- Home /
Multiplayer Scoreboard Problem.
Im trying to create a scoreboard but im not really sure how RPCs works, So far i have got this far, Could you tell me what i am doin wrong?
Player Script (Only relevant part):
//These are just local varibles
private int AlphaScore = 0;
private int DeltaScore = 0;
void OnTriggerEnter(Collider other) {
int ScoreToAdd = 1;
networkView.RPC("AddScoreDelta", RPCMode.All, ScoreToAdd);
}
[RPC]
void AddScoreDelta(int ScoreToAdd) {
DeltaScore += ScoreToAdd;
Debug.Log ("Walla");
}
ScoreManager Script (Only relevant part):
public int AlphaScore = 0;
public int DeltaScore = 0;
void OnGUI () {
GUI.Label (new Rect (Screen.width - 550,Screen.height - 565,100,50), AlphaScore.ToString());
GUI.Label (new Rect (Screen.width - 825,Screen.height - 565,100,50), DeltaScore.ToString());
}
[RPC]
void AddScoreDelta(int ScoreToAdd) {
DeltaScore += ScoreToAdd;
Debug.Log ("Walla");
}
Answer by Seizure · Aug 22, 2013 at 08:21 PM
RPCS are based on their name and transcend scripts, naming the function the same on both scripts will actually only run one of the functions. So what happens with RPC's is that when the function is called it will run on every other game object that has that script with that function in it.
Your answer
Follow this Question
Related Questions
View ID AllocatedID: # not found during lookup. Strange behaviour may occur 1 Answer
Acess server stuff by the client 0 Answers
How to use Unet to send network messages like RPC (Javascript) 0 Answers
how to properly clean up the NetworkView to prevent errors ? 0 Answers
RPCMode.AllBuffered Basic Question 1 Answer