中EN

Remote Procedure Calls

  • Called locally, execute remotely. Unidirectional, cannot return a value. Primary use: unreliable gameplay events that are transient or cosmetic (sounds, particles, animations). Must be called from a replicated actor/component. Ownership determines where RPCs execute.
  • Types: Client (owning client connection), Server (executed on server; must be called from the owning client), Remote (remote side; actor owned by a client; never local; not exposed to Blueprint), NetMulticast (server and all clients for which actor is relevant; called from client only executes locally).
  • Structure: UFUNCTION(Client) void ClientRPC(); implement ClientRPC_Implementation. Naming convention prefix Client/Server/Multicast.
  • Server RPC matrix: called from client not owning → Dropped. Client RPC called from server with no owner → runs on Server. Multicast from server → server + relevant clients.
  • Reliable: re-sent until acknowledged; subsequent RPC executions suspended until acknowledged; in order. Unreliable: dropped if packet lost; no order. RPCs are unreliable by default; reliable costs bandwidth.
  • Send policy ERemoteFunctionSendPolicy: Default, ForceSend (only Replication Graph and Iris), ForceQueue. Bunch = collection of property changes and RPCs for a replicated object; packet has several bunches.
  • WithValidation: _Validate returns bool; fail → invoking client is disconnected ("trust and verify").
  • Blueprint: Custom Event → Replicates settings.

引用这一章的笔记

输入关键词开始搜索

滚轮或双指缩放 · 拖动平移 · 双击放大 / 还原