UAbilitySystemComponent::OnComponentDestroyed
#include "AbilitySystemComponent.h"
Access: public
Specifiers: virtualoverride
Description
Called when the component is about to be destroyed. Cancels all active abilities and removes all gameplay effects before the object is garbage collected.
Caveats & Gotchas
- • Call Super::OnComponentDestroyed() — the base implementation ends all active gameplay tasks and abilities; skipping it will leave dangling ability instances.
- • Unlike UninitializeComponent, this path is only taken on true destruction (not component unregistration), so cleanup logic that must run exactly once belongs here rather than in UninitializeComponent.
Signature
virtual void OnComponentDestroyed(bool bDestroyingHierarchy) override Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| bDestroyingHierarchy | bool | True when the entire actor hierarchy is being destroyed rather than just this component. | — |
Return Type
void Example
Override that clears custom state before destruction C++
void UMyAbilitySystemComponent::OnComponentDestroyed(bool bDestroyingHierarchy)
{
// Release any custom handles before the ASC tears down
ActiveAbilityHandles.Empty();
Super::OnComponentDestroyed(bDestroyingHierarchy);
} Tags
Version History
Introduced in: 4.15
| Version | Status | Notes |
|---|---|---|
| 5.6 | stable | — |
Feedback
Was this helpful?