Skip to main content

Networking & replication

TPScript exposes Unreal's networking specifiers so you can mark up properties and functions for replication. This page is honest about what TPScript generates today versus what's on the roadmap.

Replication specifiers you can use​

Property specifier:

prop public bool bIsOpen protected EditAnywhere Replicated category="Door" default=false

Function specifiers on func:

func public void SetOpen(bool Open) Server Reliable { ... }

Available function specifiers: Server, Client, NetMulticast, Reliable, Unreliable, WithValidation, plus BlueprintAuthorityOnly / BlueprintCosmetic.

The full replicated door pattern (classic)​

05-lowlevel-door.tps demonstrates the classic setup: a replicated bIsOpen, a multicast OnDoorOpened delegate, three components, timers, and clamping.

uclass ADoorReplicated : AActor meta: api=MYGAME_API
{
declare DynamicMulticast FExampleDoorOpened (OneParam APawn*, Opener)

prop public bool bIsOpen protected EditAnywhere Replicated category="Door" default=false
field public FExampleDoorOpened OnDoorOpened
field public FTimerHandle AutoCloseTimer

component UBoxComponent "Trigger"
component UStaticMeshComponent "DoorMesh"
component UAudioComponent "DoorSound"

func public void SetOpen(bool Open) Server Reliable {
if (bIsOpen == Open) { return; }
bIsOpen = Open;
OnDoorOpened.Broadcast(GetInstigator());
}

func public void Server_OpenDoor() Server Reliable {
UE_LOG(LogTemp, Warning, TEXT("pos=%s rot=%s"), *GetActorLocation().ToString(), *GetActorRotation().ToString());
}

method public bool IsOpen() const { return bIsOpen; }

ctor {
Trigger = CreateDefaultSubobject<UBoxComponent>(TEXT("Trigger"));
DoorMesh = CreateDefaultSubobject<UStaticMeshComponent>(TEXT("DoorMesh"));
RootComponent = Trigger;
DoorMesh->SetupAttachment(Trigger);
}
}

Important: what is and isn't generated today​

The transpiler parses and passes through Replicated / Server / NetMulticast / Reliable / Unreliable and the delegate machinery. However:

  • ⚠️ GetLifetimeReplicatedProps() is NOT auto-generated yet.
  • ⚠️ _Implementation() stubs for Server/Reliable functions are NOT auto-generated yet.

This means full wired replication (the part where Unreal actually syncs bIsOpen across actors and routes Server RPCs) is on the roadmap, not yet emitted. The specifiers are present in the generated header macros so you can author them, but to get a truly replicated actor you currently add the small lifetime/wiring code yourself (or use the classic pattern above and fill in GetLifetimeReplicatedProps by hand in the .cpp).

Roadmap

Full networked replication (lifetime replication + RPC _Implementation generation) is planned. It is not yet code-generated by the transpiler.

Authoring tips that already work​

  • Route client writes through Server functions - clients call SetOpen(...); the Server, Reliable variant applies authority.
  • Use HasAuthority() to branch server- vs client-only logic.
  • Use GetLocalRole() / GetRemoteRole() when you need role checks.
  • ReplicatedUsing = OnRep_... is recognized - declare the OnRep_ method yourself and it will be wired in the property.

Example 05​

Full source is in Examples/05-lowlevel-door.tps. It's also a great example of clamping (clamp=), delegates, and timers together in one file.

Next: Best practices.