Search Unity

Are RPC's possible with client and server in different scene?

Discussion in 'Multiplayer' started by Ultimatemau, Mar 7, 2011.

  1. Ultimatemau

    Ultimatemau

    Joined:
    Mar 1, 2011
    Posts:
    17
    Hi,

    I'm making an application where i have the client in 1 project and the server in another. If i do my RPC call on the server to all clients it gives this error on the clientside:

    "View ID SceneID: 1 Level Prefix: 0 not found during lookup. Strange behaviour may occur" and
    "Could't invoke RPC function 'RandomCall' because the networkView 'SceneID: 1 Level Prefix: 0' doesn't exist"

    My code on server side is as follows:

    public void RandomFunctionCall()
    {
    if (Network.connections.Length > 0)
    {
    networkView.RPC("RandomCall", RPCMode.Others, "random");
    }
    else if (Network.connections.Length == 0)
    {
    Debug.Log("No clients connected");
    }
    }

    [RPC]
    public void RandomCall(string str)
    {
    //Debug.Log(str + "Server");
    }

    My code on the clients side is as follows:

    [RPC]
    public void RandomCall(string str)
    {
    Debug.Log(str);
    }

    Note: Every gameobject that these scipts (client and server) are on have a Network view Component on them with State Sync off and None in the Observed slot.

    Question: Am i forgetting something? Is it possible to send out RPC calls to a client in a different project?
     
  2. Ultimatemau

    Ultimatemau

    Joined:
    Mar 1, 2011
    Posts:
    17
    Shameless bump but i realy need help on this one. I didn't just post this question without trying to find answers myself first.

    Thnx in advance for the help
     
  3. Quietus2

    Quietus2

    Joined:
    Mar 28, 2008
    Posts:
    2,058
    The client and server are required to both be part of the same project.

    You can however use preprocessor directives to isolate the client and server code during the build.

    Code (csharp):
    1.  
    2. #ifdef BUILDTYPE_SERVER
    3. // Code
    4. #endif
    5.  
     
  4. mgebra

    mgebra

    Joined:
    Sep 22, 2010
    Posts:
    27
    Check NetworkView viewID in client and server. They should be same.
     
  5. Ultimatemau

    Ultimatemau

    Joined:
    Mar 1, 2011
    Posts:
    17
    Thanks you mgebra! I didn't know they had to be the same...

    Cheers