RealDocs

AActor::AllowActorComponentToReplicate

function Engine Since 4.27
#include "GameFramework/Actor.h"
Access: public Specifiers: virtual

Description

Override to control whether a component that wants to replicate is actually allowed to, and to which connections. Return COND_Never to block replication entirely, COND_None to replicate to all, or any other ELifetimeCondition to filter by ownership or other criteria.

Caveats & Gotchas

  • Return value is an ELifetimeCondition, not a bool — returning COND_None means 'allow to everyone', not 'deny'.
  • The default implementation returns COND_None for all components. Only override if you need actor-level control over component replication.
  • This is called once when the component is added to the replication list, not per-tick. Changing the policy later requires calling SetReplicatedComponentNetCondition.

Signature

ENGINE_API virtual ELifetimeCondition AllowActorComponentToReplicate(const UActorComponent* ComponentToReplicate) const

Parameters

Name Type Description Default
ComponentToReplicate const UActorComponent* The component that is requesting permission to replicate.

Return Type

ELifetimeCondition

Example

Restrict a component to the owning client only C++
ELifetimeCondition AMyActor::AllowActorComponentToReplicate(const UActorComponent* ComponentToReplicate) const
{
    if (ComponentToReplicate == PrivateInventoryComponent)
    {
        return COND_OwnerOnly;
    }
    return Super::AllowActorComponentToReplicate(ComponentToReplicate);
}

Version History

Introduced in: 4.27

Version Status Notes
5.6 stable

Feedback

Was this helpful?

Suggest an edit

Select a field above to begin editing.