Do RPCs still run through the network if the client and server (ie host) are the same?

In a multiplayer game using NGO, I have a local option which also serves as the single player option. In this game you can pick things up. To do this I just emit an event from the player via an RPC

// Player
[ServerRpc]
private void InvokeItemClickedServerRpc(NetworkBehaviourReference item)
 {
    Cursor.OnItemClickedEventArgs args = new(item);
    this.OnItemClicked?.Invoke(this, args);
}

// Game
private void AttachPlayerHandlers(Player player)
{
  player.OnItemClicked += this.HandlePlayerOnItemClicked;
}

First of all, it’s incredible how that works… but it is a very strange way to write code. But to my question: if Player is on the same machine as the server (host) than is a network message still sent? Do I need to expect a bit of delay for a network message to be received on the host, from the host?

No. Server RPCs on the host are instant method invocations.

No, but you should. I always add the Defered flag to the [Rpc] attribute. This serves two purposes: you are not fooled by a no-latency code path because even just a single frame of delay can reveal quite a number of issues you might not otherwise catch until you test as a client. The other reason is that if you’re not careful you may get yourself into an infinite loop (should throw a stackoverflow but I recall I’ve also had the editor freeze on me before).

The single-frame delay shouldn’t be an issue in singleplayer since with 1 frame latency you’ll still be playing the game as if you were under perfect (LAN) conditions. So whatever works in multiplayer will be fine in singleplayer and still feel more responsive even.

Also note you are using the outdated [ServerRpc] which is less flexible than [Rpc].

Great insights! Thank you