Issue in example for 1.8.0

In the below code (from RPC | Unity Multiplayer Networking) , doesnt PingRpc need a parameter ??

[Rpc(SendTo.Server)]
public void PingRpc(int pingCount)
{
    // Server -> Clients because PongRpc sends to NotServer
    // Note: This will send to all clients.
    // Sending to the specific client that requested the pong will be discussed in the next section.
    PongRpc(pingCount, "PONG!");
}

[Rpc(SendTo.NotServer)]
void PongRpc(int pingCount, string message)
{
    Debug.Log($"Received pong from server for ping {pingCount} and message {message}");
}

void Update()
{
    if (IsClient && Input.GetKeyDown(KeyCode.P))
    {
        // Client -> Server because PingRpc sends to Server
        PingRpc();
    }
}

This is a known issue in the documentation and it does need a parameter:

private int m_Count;

void Update()
{
    if (IsClient && Input.GetKeyDown(KeyCode.P))
    {
        // Client -> Server because PingRpc sends to Server
        m_Count++;
        PingRpc(m_Count);
    }
}

The documentation should be updated soon with fixes to a few known existing issues in the most recent update.

1 Like