RPC
To make an extension compatible with Skyreal VR collaboration mode, you need to understand how network replication works in Unreal Engine.
Reference: Unreal Engine Networking Overview
Unreal Datamodel Replication
[IMAGE: Unreal datamodel replication diagram — original at /pictures/v1.16/Network_UEDatamodel.jpg]
|
Class |
Per App |
Per Map |
Per User |
On Server |
On Clients |
|---|---|---|---|---|---|
|
Game Instance |
Yes |
— |
— |
— |
— |
|
Game Mode |
— |
Yes |
— |
— |
— |
|
Game State |
— |
Yes |
— |
Yes |
Yes |
|
Player Controller |
— |
— |
Yes |
Yes |
— |
|
Pawn |
— |
— |
Yes |
Yes |
Yes |
Replication Basics (Server → Client)
To replicate an actor from server to clients, check Replicates in Class Defaults. Then tag individual properties as Replicated or RepNotify.
[IMAGE: Replicate actor — original at /pictures/v1.16/Network_ReplicateObject.png]
-
Replicated — Variable synced without additional behavior.
-
RepNotify — Variable synced with a callback function executed on the client when the value changes.
[IMAGE: RepNotify example — original at /pictures/v1.16/Network_ReplicateNotify.png]
RPC Requests (Client → Server)
Only objects with local ownership (Player Controller, Pawn) can send requests to the server. Skyreal VR provides the RPCInterfaceComponent to simplify this.
Creating an RPC Component
-
In
RegistrableAssets, create a DataAsset inheriting from SkrRPCInterfaceComponentDescription.
[IMAGE: RPC data asset — original at /pictures/v1.16/Network_ReplicateRPC0.png]
-
Click + on ComponentClassToSpawn to create a new SkrRpcInterfaceComponent. Save it outside
RegistrableAssets.
[IMAGE: RPC component creation — original at /pictures/v1.16/Network_ReplicateRPC1.png]
-
Open the component and create a custom event. Set Replicates to Run on Server in the details panel.
[IMAGE: RPC server event — original at /pictures/v1.16/Network_ReplicateRPC3.png]
-
Call this method from anywhere in your code — it executes on the server regardless of which instance calls it.
[IMAGE: RPC call example — original at /pictures/v1.16/Network_ReplicateRPC5.png]
Spawning Actors as a Client
Use the SkrActorSpawnerRpcDispatcher to spawn replicated actors from any client. This is a latent function (spans multiple frames without blocking the game thread).
[IFRAME: Actor spawning blueprint sample — original at https://blueprintue.com/render/wqi78tcn/]