AActor::OnRep_AttachmentReplication
#include "GameFramework/Actor.h"
Access: public
Specifiers: UFUNCTIONvirtual
Description
RepNotify called on clients when the `AttachmentReplication` property changes, causing the engine to apply the new attachment transform and socket on the client.
Caveats & Gotchas
- • Do not call this directly — it is invoked automatically by the replication system. Calling it manually will not replicate anything; it only applies already-received data.
- • When overriding, always call `Super::OnRep_AttachmentReplication()` to ensure the engine performs the actual attach/detach. Omitting the Super call will leave the client in a visually incorrect state.
- • If you need to react to an actor being attached on the client, this is the correct hook. However, note it fires only when `AttachmentReplication` changes — if the socket or offset changes but the parent does not, the update may be batched with movement replication instead.
Signature
UFUNCTION()
ENGINE_API virtual void OnRep_AttachmentReplication(); Return Type
void Example
Play a snap effect when attachment changes on client C++
void AMyActor::OnRep_AttachmentReplication()
{
Super::OnRep_AttachmentReplication();
// Play VFX at new location after engine applies attachment
UGameplayStatics::SpawnEmitterAtLocation(this, AttachVFX, GetActorLocation());
} See Also
Tags
Version History
Introduced in: 4.12
| Version | Status | Notes |
|---|---|---|
| 5.6 | stable | — |
Feedback
Was this helpful?