Hello,
I have a question regarding RPC variables in a network, because I’m abit confused -
I’m making an online rock-paper-scissors game-
I have 2 gameobjects in the scene, each one controlled by a different client. on both gameobjects there’s the same script with networkview activated.
I have 2 private variables in the script, one for each player decision.
I use an RPC function to update these variables, depending on the tag of the gameobject -
so for example a player controls the gameobject with the tag “player2”, when he makes a decision - the function updates the variables that correspondes to player2.
the problem is - the clients won’t recongnize the variables of the other clients -
so if i’m player1, I can’t access the variable of player2, and vise versa.
Am I missing something? how can I get all clients access to every variable in the script?
What do you mean with RPC variables ? RPC means remote procedure calls, they are just a way to call a function on a remote computer... Are you talking about arguments ? If you call some RPC with an argument, the RPC will be performed with this same argument value on every computer in RPCMode
– CorentinThere are a limited number of types of variables that can be sent as arguments to an RPC. Are you trying to send something like a GameObject or Material as an argument? Because that won't work. But that's just a guess. Post the script you're talking about if you want someone to be able to actually give you an answer.
– KiloblarghI'm giving strings as arguements... here are the relevant pieces of the code: private string dp1; private string dp2; void OnGUI() { if(GUI.Button(new Rect((100,100,,150,75),shoot)) networkView.RPC("SetDecision", RPCMode.AllBuffered, "Shoot"); } [RPC] void SetDecision (string decision) { if(this.tag=="Player1") dp1=decision; if(this.tag=="Player2") dp2=decision; }
– danlinenberg