Search Unity

OnSerializeNetworkView not working properly?

Discussion in 'Multiplayer' started by MikeHergaarden, Apr 17, 2009.

  1. MikeHergaarden

    MikeHergaarden

    Joined:
    Mar 9, 2008
    Posts:
    1,027
    OnSerializeNetworkView does not seem to work properly. I want to use the GraduallyUpdateState.cs script in a multiplayer FPS setting where the server itself is not always dedicated..the server itself can be a in-game player, and thus a 'client'.

    GraduallyUpdateState works perfect for clients in this FPS game, however, if the host(the server) is a player itself..the OnSerializeNetworkView function will not recieve nor send on the servers object. It works fine on the other players objects though. I want it to also send the servers position to the other clients...

    My nasty workaround for this problem is to RPC the servers position to other clients (and still use GraduallyUpdateState for clients). Am I missing something, or am I right to assume this a networking bug/missing feature?
     
  2. Dreamora

    Dreamora

    Joined:
    Apr 5, 2008
    Posts:
    26,601
    This is likely a setup problem, because the Network Example Projects clearly work in exactly this scenario.

    You could compare the setup of your end with that to find out whats going wrong. Never worked with the FPS sample.
    My guess is network view id / instanciation.

    The example can be found in the support-resource section of the page.
     
  3. MikeHergaarden

    MikeHergaarden

    Joined:
    Mar 9, 2008
    Posts:
    1,027
    Hm, "TPS-Auth" only uses a dedicated server and GraduallyUpdateState. So this does not demonstrate my problem.

    The "Third Person" scene with the NetworkInterpolation script does seem to work well with OnSerializeNetworkView..so I'll have to double check my scripts indeed!
     
  4. Dreamora

    Dreamora

    Joined:
    Apr 5, 2008
    Posts:
    26,601
    TPS-Auth does not require a dedicated server. Works with you as player and client too.
    What it thought does is leave the world state update to the server only, without letting the user decide about that (usefull for board games, round based games and alike where you send actions to the server and the server first validates and then executes the action for example. Generally even RTS would qualify for this kind of networking). For that reason it does use the whole networking slightly different (all server managed, not client managed), there you are right.

    glad that the third person thought works on your end and gives you a possibility to dissect your problem.
     
  5. susdorf

    susdorf

    Joined:
    May 29, 2009
    Posts:
    60
    What I did, was adding a simple code snippet to GraduallyUpdateState in the "MonitorLocalMovement" function:
    Code (csharp):
    1.  
    2. if(Network.isServer)
    3.   m_BufferedState[0] = m_LocalBufState[0];
    4.  
    So all local transformation are simultaneously global server transformations, if the player is the server.