Skip to content

Remote calls

How do I call a function on the server or on clients?

Use @ue.ufunction with server, client or multicast.

@ue.uclass
class PyDoor(ue.Actor):
    is_open: bool = ue.uproperty(False, replicated=True)

    @ue.ufunction(server=True, reliable=True)
    def server_interact(self, who: str) -> None:
        """Runs on the server, whoever calls it."""
        self.is_open = not self.is_open

    @ue.ufunction(multicast=True)
    def play_effect(self) -> None:
        ue.log("effect")
Kind Runs on
server=True the server
client=True the owning client
multicast=True the server and every client
reliable=True add to any of the above: the call is never dropped

Choose one kind. reliable only applies to remote functions. Both mistakes raise TypeError at definition.

Notes

  • Call it as a normal method; the call goes through Unreal and reaches the other side like a Blueprint or C++ call.
  • A client can only call a server function on an actor it owns. Set the owner on the server (door.set_owner(player_controller)).
  • An override of a remote function is remote too, with the settings of the function it overrides. Stating different settings is a definition error.
  • Calling the parent version from an override (super().fire()) runs the parent's code where the override runs; it does not send a call.