RPCs (Remote Procedure Calls)

RPCs allow you to invoke functions across the network, enabling communication between the server and clients. These examples are parameterless, but of course they can contain parameters.

If you want a RPC to be unreliable, just don’t declare FunctionFlags.Reliable

Run on Server

Use the [UFunction] attribute with FunctionFlags.RunOnServer to indicate that a method should be executed on the server:

[UFunction(FunctionFlags.RunOnServer | FunctionFlags.Reliable)]
public void ServerFunction()
{
    // Server-side code
}

Run on Owning Client

Similarly, to execute a function on the owning client, use FunctionFlags.RunOnClient:

[UFunction(FunctionFlags.RunOnClient | FunctionFlags.Reliable)]
public void ClientFunction()
{
    // Client-side code
}

Multicast

For functions that should be executed on both the server and all clients, use FunctionFlags.Multicast:

[UFunction(FunctionFlags.Multicast | FunctionFlags.Reliable)]
public void MulticastFunction()
{
    // Code executed on both server and clients
}

Last updated