AActor::DetachFromActor
#include "GameFramework/Actor.h"
Access: public
Specifiers: UFUNCTIONBlueprintCallable
Description
Detaches this actor's RootComponent from its current parent, releasing the attachment. Pass FDetachmentTransformRules::KeepWorldTransform to keep the actor in its current world position; pass KeepRelativeTransform to revert to the pre-attachment local offset.
Signature
void DetachFromActor(const FDetachmentTransformRules& DetachmentRules) Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| DetachmentRules | const FDetachmentTransformRules& | Rules controlling how the actor's transform is treated after detachment. Use FDetachmentTransformRules::KeepWorldTransform to maintain current world position. | — |
Return Type
void Caveats & Gotchas
- • EDetachmentRule::KeepWorld preserves the actor's current world-space position and rotation after detachment. EDetachmentRule::KeepRelative keeps the relative offset, which will snap the actor if the parent was transformed since attachment.
- • If the actor is not currently attached, this call is a no-op.
- • This detaches the root component attachment only. If child components are separately attached to parent components, those are not affected.
Example
Drop a held item and keep it in place C++
// In the character — release a held item and leave it at its world position
PickupActor->DetachFromActor(FDetachmentTransformRules::KeepWorldTransform);
PickupActor->GetRootComponent()->SetSimulatePhysics(true); Tags
Version History
Introduced in: 4.0
| Version | Status | Notes |
|---|---|---|
| 5.6 | stable | — |
Feedback
Was this helpful?