RealDocs

UAbilitySystemComponent::ReplicateSubobjects

function GameplayAbilities Since 4.15
#include "AbilitySystemComponent.h"
Access: public Specifiers: virtualoverride

Description

Called by the replication system to replicate gameplay ability instances and other subobjects owned by this component. Override to add additional subobjects that need to be sent over the network.

Caveats & Gotchas

  • Always call Super::ReplicateSubobjects() when overriding; skipping it will prevent ability instances and attribute sets from replicating to clients.
  • This is called on the server's net tick — heavy per-frame work here can degrade replication bandwidth; use conditional replication (GetLifetimeReplicatedProps) rather than spawning extra subobjects.

Signature

UE_API virtual bool ReplicateSubobjects(class UActorChannel *Channel, class FOutBunch *Bunch, FReplicationFlags *RepFlags) override

Parameters

Name Type Description Default
Channel class UActorChannel* The actor channel being replicated over.
Bunch class FOutBunch* The outgoing replication bunch.
RepFlags FReplicationFlags* Flags controlling replication behaviour (e.g. initial replication, owner-only).

Return Type

bool

Example

Override to add a custom replicated subobject C++
bool UMyAbilitySystemComponent::ReplicateSubobjects(
    UActorChannel* Channel, FOutBunch* Bunch, FReplicationFlags* RepFlags)
{
    bool bWroteSomething = Super::ReplicateSubobjects(Channel, Bunch, RepFlags);
    if (IsValid(MyReplicatedSubobject))
    {
        bWroteSomething |= Channel->ReplicateSubobject(
            MyReplicatedSubobject, *Bunch, *RepFlags);
    }
    return bWroteSomething;
}

Version History

Introduced in: 4.15

Version Status Notes
5.6 stable

Feedback

Was this helpful?

Suggest an edit

Select a field above to begin editing.