Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice

[Server] SomeFunction vs [Command] CmdSomeFunction vs [Server] CmdSomeFunction

Discussion in 'Multiplayer' started by DSebJ, Feb 2, 2016.

  1. DSebJ

    DSebJ

    Joined:
    Mar 30, 2013
    Posts:
    101
    Hi,

    Whats the difference between

    Code (CSharp):
    1.  [Server]
    2.   public void CountDownLevelChange(){
    3.  
    4. ......
    and

    Code (CSharp):
    1.  [Command]
    2.   public void CmdCountDownLevelChange(){
    3.  
    4. ......
    and

    Code (CSharp):
    1.  [Server]
    2.   public void CmdCountDownLevelChange(){
    3.  
    4. ......
    I think the 3rd is just the wrong syntax but I wasn't getting any compile errors and it seemed that the code was being triggered from the clients to the server even through the custom attribute was set to Server?
     
  2. Cafn

    Cafn

    Joined:
    Jan 8, 2015
    Posts:
    19
    I'm not fully sure, but I believe that 1st one and 3rd one is the same, only difference is the name of the function.

    [Command] is when a client calls something on the server. Note that the server can be a client too.