Search Unity

The ping in scoreboard is always 0

Discussion in 'Multiplayer' started by ARares, Aug 9, 2017.

  1. ARares

    ARares

    Joined:
    Mar 18, 2016
    Posts:
    167
    I did this to can show the ping in the scoreboard for each player, but for all players the ping is 0:

    And i get this warning: Trying to send command for object without authority.

    Code (CSharp):
    1.     [SyncVar]
    2.     public int playerPing = 0;
    3.  
    4.     void Update()
    5.     {
    6.         CmdShowPing(); //Warning Here
    7.     }
    8.  
    9.  
    10.     [Command]
    11.     private void CmdShowPing()
    12.     {
    13.         if (NetworkManager.singleton != null)
    14.         {
    15.             playerPing = NetworkManager.singleton.client.GetRTT();
    16.         }
    17.     }
     
  2. TwoTen

    TwoTen

    Joined:
    May 25, 2016
    Posts:
    1,168
    Only call the command if you have authority. (if hasAuthority)
     
  3. ARares

    ARares

    Joined:
    Mar 18, 2016
    Posts:
    167
    ok, the warning is fixed, but the ping is always 0:
    Untitled.png
     
  4. TwoTen

    TwoTen

    Joined:
    May 25, 2016
    Posts:
    1,168
    GetRTT is null on the server. You need to get the client connection that you want to measure


    EDIT:
    I meant the Client on the NetManager is null. Atleast So I think
     
    Last edited: Aug 10, 2017