Unity Netcode for Game Objects method "GetCurrentRtt" does not accept Local Client ID?

163 views Asked by At
private void Update()
    {
        if(NetworkManager.Singleton != null && NetworkManager.Singleton.IsConnectedClient)
        {
            float pingInMilliseconds = NetworkManager.Singleton.NetworkConfig.NetworkTransport.GetCurrentRtt(NetworkManager.Singleton.LocalClientId);
        }

    }

Although GetCurrentRtt() asks for a Client ID, this seems to cause a "KeyNotFoundException: The given key '1' was not present in the dictionary." error.

One possible fix I tried is decrementing 1 from the LocalClientID, which actually made it work... for the first user only. Any other users logging in would again throw an error.

1

There are 1 answers

0
creeperQ7 On

For anyone looking for an answer to this question in the future, I actually found one:

GetCurrentRtt() requires a NetworkManager.ServerClientId if you are running it from the client side, since you are checking for a connection from you (the client) to the Server.