Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

AllocateVIewID? I don't get it

Discussion in 'Multiplayer' started by Moredice_legacy, Feb 25, 2010.

  1. Moredice_legacy

    Moredice_legacy

    Joined:
    Jan 31, 2010
    Posts:
    101
    Hi, I currently got a persistent prefab object with both server-specific and client specific scripts attached already in the scene (not instantiated).

    The server is dedicated (it does not have the same code as the client), and I disable the client scripts on the prefab when I build the server standalone. Then I disable the server scripts and enable client scripts when testing from editor.

    I have a problem with Network.AllocateViewID(). If I don't allocate a viewID, the scene view is used instad, which neither client nor server understands basically.

    Server can allocate it's own viewID without problems, same with client. But, when I try to send an RPC from server to client, or client to server, I'm getting this error:

    * View ID AllocatedID: 1 not found during lookup. Strange behaviour may occur.
    * Couldn't invoke RPC function 'TEST' because the networkView 'AllocatedID: 1' does't exist.


    I know this means that the server doesn't have the same view ID set for the client, and vice versa.

    How do I allocate the viewID's and communicate it back and forth to synch the viewID's when this error message always pops up? As in, how do I allocate viewID to the client's game object from the server and send it?

    Can I access the player's game object when it's not instantiated on the server, but is a persistent object for the client? (I am hard-guessing a "no" here.)

    The NetworkView state synch is set to off and it's not observing anything since I'm not using OnSerializeNetworkView. Should I be using this to solve this problem?

    The instantiation of objects happens later when the client enters the game world, by the way.



    Edit: Forgot to mention, the error I got in the client debugger was given when I tried to use this code on the server:
    Code (csharp):
    1.  
    2. function OnPlayerConnected(player : NetworkPlayer) {
    3.     networkView.RPC("TEST", player, Network.AllocateViewID());
    4.     if (!isAuth) {
    5.         totalConCount += 1;
    6.     }
    7. }
    8.  
    And yes, I have also tried using RPCMode.Others, RPCMode.All, etc.

    Anyone?


    Edit 2: Removed images/image links.
     
  2. Moredice_legacy

    Moredice_legacy

    Joined:
    Jan 31, 2010
    Posts:
    101
    Fixed broken image URL's.

    And a bump, no one has any answers?
     
  3. Moredice_legacy

    Moredice_legacy

    Joined:
    Jan 31, 2010
    Posts:
    101
  4. oxl

    oxl

    Joined:
    Nov 21, 2008
    Posts:
    325
    How ?

    --
    oxl
     
  5. Moredice_legacy

    Moredice_legacy

    Joined:
    Jan 31, 2010
    Posts:
    101
    By manually allocating view ID's.