UActorChannel::ReplicateSubobject

Subobject Replication state

Windows
MacOS
Linux

References

Module

Engine

Header

/Engine/Source/Runtime/Engine/Classes/Engine/ActorChannel.h

Include

#include "Engine/ActorChannel.h"

Source

/Engine/Source/Runtime/Engine/Private/DataChannel.cpp

Syntax

bool ReplicateSubobject
(
    UObject * Obj,
    FOutBunch & Bunch,
    const FReplicationFlags & RepFlags
)

Remarks

Subobject Replication state

Concepts: ObjID - this is an arbitrary identifier given to us by the game code. RepKey - this is an idenifier for the current replicated state.

ObjID should be constant per object or "category". Its up to the game code. For example the game code could use 0 to determine if an entire array is dirty, then usen 1-N for each subobject in that list. Or it could have 5 arrays using 0-4, and then use 100*ArrayNum + idx for the items in the array.

RepKey should change as the subobject changes. Each time a subobject is marked dirty, its RepKey should change.

GameCode should call ::KeyNeedsToReplicate(ObjID, RepKey) to determine if it needs to replicate. For example:

bool AMyActorClass::ReplicateSubobjects(UActorChannel *Channel, FOutBunch *Bunch, FReplicationFlags *RepFlags) { bool WroteSomething = false;

if (Channel->KeyNeedsToReplicate(0, ReplicatedArrayKey) ) // Does the array need to replicate? { for (int32 idx = 0; idx < ReplicatedSubobjects.Num(); ++idx ) { UMyActorSubobjClass *Obj = ReplicatedSubObjects[idx]; if (Channel->KeyNeedsToReplicate(1 + idx, Obj->RepKey)) { WroteSomething |= Channel->ReplicateSubobject(Obj, *Bunch, *RepFlags); } } }

return WroteSomething; }

void UMyActorSubobjClass::MarkDirtyForReplication() { this->RepKey++; MyOwningActor->ReplicatedArrayKey++; }

Replicates given subobject on this actor channel

Select Skin
Light
Dark

Welcome to the new Unreal Engine 4 Documentation site!

We're working on lots of new features including a feedback system so you can tell us how we are doing. It's not quite ready for use in the wild yet, so head over to the Documentation Feedback forum to tell us about this page or call out any issues you are encountering in the meantime.

We'll be sure to let you know when the new system is up and running.

Post Feedback