RealDocs

AActor::DetachAllSceneComponents

function Engine Since 4.0
#include "GameFramework/Actor.h"
Access: public

Description

Detaches all SceneComponents in this Actor that are attached to the supplied parent SceneComponent. Use this to cleanly sever a specific attachment hierarchy without destroying components.

Caveats & Gotchas

  • Only components directly attached to InParentComponent are detached — deeply nested children attached to other intermediaries are not affected unless you recurse manually.
  • FDetachmentTransformRules::KeepWorldTransform is usually the safe default; using KeepRelativeTransform after detachment will leave components at their relative-to-origin positions, which is rarely intended.

Signature

ENGINE_API void DetachAllSceneComponents(class USceneComponent* InParentComponent, const FDetachmentTransformRules& DetachmentRules)

Parameters

Name Type Description Default
InParentComponent USceneComponent* The parent scene component from which all of this actor's components should be detached.
DetachmentRules const FDetachmentTransformRules& Rules controlling how transforms are handled when components are detached (keep world transform, keep relative, reset, etc.).

Return Type

void

Example

Detach weapon mesh from hand socket C++
if (USceneComponent* HandSocket = GetComponentByClass<USceneComponent>())
{
    DetachAllSceneComponents(HandSocket, FDetachmentTransformRules::KeepWorldTransform);
}

Version History

Introduced in: 4.0

Version Status Notes
5.6 stable

Feedback

Was this helpful?

Suggest an edit

Select a field above to begin editing.