UActorComponent::SetIsReplicated
#include "Components/ActorComponent.h"
Access: public
Specifiers: UFUNCTIONBlueprintCallable
Description
Enables or disables replication for this component. This is the component equivalent of AActor::SetReplicates — the owning actor must also replicate for this to have any effect.
Caveats & Gotchas
- • The owning actor must have bReplicates=true. Enabling replication on a component whose actor does not replicate will silently have no effect.
- • Must be called before or during component registration (typically in the constructor) for reliable results. Setting it after BeginPlay on a live connection may not replicate existing state to already-connected clients.
- • Component replication incurs bandwidth cost. Only replicate components that actually have state needing synchronization — consider using RPCs on the actor instead for infrequent updates.
Signature
UFUNCTION(BlueprintCallable, Category="Components")
ENGINE_API void SetIsReplicated(bool ShouldReplicate) Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| ShouldReplicate | bool | Whether the component should replicate its state to clients. | — |
Return Type
void Example
Enable component replication in the constructor C++
UMyNetworkComponent::UMyNetworkComponent()
{
SetIsReplicated(true);
} Tags
Version History
Introduced in: 4.0
| Version | Status | Notes |
|---|---|---|
| 5.6 | stable | — |
Feedback
Was this helpful?