- Home /
 
RPC and how to talk to clients
hey i ve been reading these forums for quite a while and this problem has really got into me that's how i decided to create an account and participate to you exciting community. Anyway to the point.
I am making a Risk kind of game , multiplayer. I have a script "GameController" where i create an array that i store which players owns which territory called territories[] (so terratories[1]=3 means that territory [1](lets say Alaska) is owned by player 3).
Each territory has a script that the intention is for the server side of the script to broadcast who owns the territory to all clients.
  function Update () {
     if(owned==null && Network.isServer){
         owned=GameObject.Find("GameController").GetComponent(GameController).terratories[MyID];
         Colour();   //color the territory depending on who owns it
         networkView.RPC("GetWhoOwnsMe",RPCMode.All,owned);    
     }
 }
     //client side
 @RPC
 function GetWhoOwnsMe (who : int){
     owned=who;
     Colour();
 }
 
               but the client side of the script (function GetWhoOwnsMe ) is never accessed.
One solution that is working is to make each client sent a message to the server and the server to individually respond to each client for each territory who owns them but i think if i can make the above work (the server to sent to all clients) will save a lot of network traffic and it seems the smart way to do it
Anyway i am new to all this networking thing i am following tutorial and all and i made it so far any more help would be really appreciated.
Your answer