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.

circle-info

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 partial void ServerFunction();
public partial void ServerFunction_Implementation();
{
    // 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 partial void ClientFunction();
public partial void ClientFunction_Implementation();
{
    // Client-side code
}

Multicast

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

Last updated