Search Unity

issue sending NetworkViewID on RPC call..

Discussion in 'iOS and tvOS' started by zyndro, Sep 18, 2011.

  1. zyndro

    zyndro

    Joined:
    Oct 19, 2010
    Posts:
    78
    Hello There!


    I'm having really hard times trying to figure out this.. and i just tried like all day and still i'm not able to find out what's the problem, maybe you guys can give me a light, i really appreciate it!


    i'm trying to send a NetworkViewID on a RPC call i'm doing this..

    Code (csharp):
    1. networkView.RPC("setHP", RPCMode.All, NetworkViewID);

    and then i do this:

    Code (csharp):
    1. @RPC
    2. function setHP(MyID : String)
    3. {
    4.  

    seems to compile ok, but in the run time, i get this error:

    Code (csharp):
    1. Expected 'System.String' but got 'System.MonoType'
    2. UnityEngine.NetworkView:RPC(String, RPCMode, Object[])

    it's a network game and what i'm trying to do is send the player's ID to everyone so i can handle it after, but i cant get it on String or Interger..

    Do you guys have an idea what can be wrong?


    Thank you so much in advance!

    Best regards,
    -Brian.
     
  2. zyndro

    zyndro

    Joined:
    Oct 19, 2010
    Posts:
    78
    Hello again!


    Well.. after some hours fighting with the code/debugger i think finally i figure out the way to do it!

    i'm not sure if this is the best way, i guess there are another more-efficient ways to get this done but well so far it's working for my needs so it's perfect for me. :)


    The RPC call was incorrect, here's what i'm using now:

    Code (csharp):
    1. networkView.RPC("setHP", RPCMode.All, Network.player);

    then at @RPC i'm using this:

    Code (csharp):
    1. @RPC
    2. function setHP(player : NetworkPlayer)
    3. {...
    4.  ...
    5.  stringVar = player.ToString();
    6.  
    and that's it.. that will storage the player's network ID in a String variable for further use.
    as i said above, i'm not sure if this is the correct or the best way to do it, but so far it's working for me and maybe can be useful for someone in the future.


    Best regards!
    -Brian.