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

RPC execution and Delay

Discussion in 'Multiplayer' started by susdorf, Aug 12, 2009.

  1. susdorf

    susdorf

    Joined:
    May 29, 2009
    Posts:
    60
    Dear Community,

    simple questions (except 3.) I could not find an answer for:

    1. Are RPC send and executed immediately or like
    State Synchronisation 15 times per second (per default)?

    2. Can someone tell me about the lagging of RPC
    if there is one?

    3. Special question:
    Are there other tested possibilities to send clients
    input in an authorative server system rather than with RPC?

    To question 3:
    The Problem is that the server is the owner of all
    players and clients objects (authorative server),
    so OnSerializeNetworkView only
    behaves on the server.

    I would like using State Synchronisation,
    sending user data, but not being the owner.
    And receiving the result State Synchronisation
    from server. Is this possible?

    Thanks.
    ...
    Some smilies for a cheerful atmosphere:
    :D :p :eek:
     
  2. susdorf

    susdorf

    Joined:
    May 29, 2009
    Posts:
    60
    Yes, I love soliloquies... really. :(
    But despite everything I have some results
    I will share with the Unity community:

    1. Yes RPC are independant from Unitys Network Managers Send Rate. So RPCs are always executed when they are called. To test this, just decrease the send rate of Unitys Network Manager and you will see the result: State Synchronisation will be decreased, the RPCs not!

    2. I had not much time to test the delay. But of course there is one inevitable: The sending time and the RPC call costs time as well. A comparision with State Synchronisation would be very interesting. But perhaps sending user data like Valves Source Engine do will solve this lagging.

    3. Yes, solved the problem until getting into a new problem: First off, having one GameObject as the player with two NetworkViews. When connecting to a server, the server allocates a NetworkViewID and refers this ID to the first NetworkView of the instantiated GameObject on both sides, the server and the client.

    During instantiating the GameObject on clients side, the client allocated a new NetworkViewID and refer this ID to its second NetworkView locally and signalise this client ID to the server. The server saves this clients generated NetworkViewID.

    Now the server is the owner of the first NetworkView component, that will just send the result transformation of a clients player.
    The client is the owner of the second NetworkView component and is therefore allowed to send. The client sends its input to the server.

    Thats what exact the situation I have needed.

    But the new problem is: With OnSerializeNetworkView you are not able to send to a specific NetworkPlayer, like you are able in RPCs. That means if there are two clients and one server, the second client will also receive the input of the first client. I feel S***ty about that situation, so I am forced to use RPCs.

    Thanks for listening and of course some smilies...


    :evil: :evil: :evil: :D
     
  3. Dreamora

    Dreamora

    Joined:
    Apr 5, 2008
    Posts:
    26,601
    2. As any networking there is lag. It is at very least as large as the lag from you to the RPC target but can be larger if the message has to be resent due to bad connection quality etc

    3. TCP / UDP sockets


    To the additional thing: don't do that, never!
    Only the owner and the server are entitled to decide about modifications on the objects.
    Other clients that just replicate it are meant to just do that: replicate it!
    What you can do, should you want to use it for "immediate response" is having virtual values for your local object that try to approximate the state and are corrected basing on the data it gets from the server and enforcing them should that be requested from the server.
     
  4. susdorf

    susdorf

    Joined:
    May 29, 2009
    Posts:
    60
    Thanks for answering dreamora, you where right. This is a bad option. After testing, experimenting and stopped when pushed forward to the Unity Bug, I have implemented now almost the same system like TPS-Auth from Unity. This works better with sending clients input through RPC to the server and receiving state synchronized transformation from server. With clients prediction, extrapolation and additional lag compensation this should be fine also in the future projects, because all kind of control is up to you.

    There is another question regarding RPC.
    When sending input through RPC to the server, does the sending client wait until the RPC function is finished on the server, or does the client continue with its game loop?

    I could not find an answer on this question and it is difficult to test.
     
  5. Dreamora

    Dreamora

    Joined:
    Apr 5, 2008
    Posts:
    26,601
    there is no reason to wait for anything (would be a bad idea as waiting for 200-300ms until you continue would be deadly for the game experience or even basic world simulation ;))