Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

ClientRpc and Command Reliable and Ordered?

Discussion in 'Multiplayer' started by davebutlerenator2, Jul 14, 2015.

  1. davebutlerenator2

    davebutlerenator2

    Joined:
    Nov 8, 2014
    Posts:
    26
    I've done a fair amount of googling and searching the forums, but I haven't been able to find an answer to this -

    Are ClientRpcs reliable and ordered? E.g. if i call two ClientRpc functions on the server, am I guaranteed that they will be called on each client in that order?

    It seems that Commands work this way (http://docs.unity3d.com/Manual/UNetActions.html), but I can't find if ClientRpcs do as well.
     
  2. peterept2

    peterept2

    Joined:
    Aug 1, 2012
    Posts:
    41
    They must be because the ClientRpc attribute defaults to channel 0, and the default channel 0 in NetworkManager is Reliable:

    Channels.DefaultReliable = 0
     
  3. GixG17

    GixG17

    Joined:
    Aug 18, 2013
    Posts:
    105
    I have no idea if this is the proper way (or related at all) but there's an "Avanced Configuration" checkbox in the Network Manager and you can set that up per Qos channel. Now, how to send an RPC on a particular channel, I have no idea.

    Would be nice to have info on whenever of not they're buffered and/or we can set them that way.
     
  4. peterept2

    peterept2

    Joined:
    Aug 1, 2012
    Posts:
    41
    If you add a new one to the advanced list, note the number it gives it. eg:

    Channel #2: Unreliable Sequenced

    Then, in any Cmd or ClientRpc you can:

    Code (CSharp):
    1. [ClientRpc(channel=2)]
    2. void RpcDamage(int damage)
    3. {
    4. ...
    5. }
     
    GixG17 likes this.
  5. davebutlerenator2

    davebutlerenator2

    Joined:
    Nov 8, 2014
    Posts:
    26
    Interesting. Any idea if ClientRpcs are reliably ordered cross-NetworkBehaviours?

    E.g. If I send a ClientRpc in Class1 on Object1, then a ClientRpc in Class2 on Object2, is the function in Class1 guaranteed to be called first on all clients?
     
  6. Bmandk

    Bmandk

    Joined:
    Aug 18, 2012
    Posts:
    70
    With my limited knowledge of networking, it should. Using the reliable option (Which is default), a client will receive and execute the Rpc's in the same order as sent. Best way to find out for sure is to just test a few times!
     
  7. aaronfranke

    aaronfranke

    Joined:
    Jan 23, 2017
    Posts:
    20
    Is there a list of all the channel numbers and their types?

    Does this all apply to TargetRPC as well?
     
  8. Joe-Censored

    Joe-Censored

    Joined:
    Mar 26, 2013
    Posts:
    11,847
    By default there are only 2 channels configured. In the Network Manager component under Advanced you can add additional channels. You can also see the default channels 0 and 1 listed. Commands, messages, and both types of RPCs should default to using channel 0.