UActorComponent::SetActive
#include "Components/ActorComponent.h"
Access: public
Specifiers: virtualUFUNCTIONBlueprintCallable
Description
Sets the component's active state in a single call — equivalent to calling Activate() or Deactivate() based on the boolean, but more convenient when toggling from data-driven logic.
Caveats & Gotchas
- • Internally just calls Activate(bReset) or Deactivate() — it is not a lower-level setter. The same ShouldActivate() checks and delegate broadcasts apply as if you called those functions directly.
- • Note from the UE source comments: 'Activate, Deactivate, and SetActive are preferred in most cases because they respect virtual behavior.' Prefer these over SetActiveFlag() which bypasses virtual dispatch and delegate broadcasting.
- • Marked UnsafeDuringActorConstruction — do not call in constructors or construction scripts.
Signature
UFUNCTION(BlueprintCallable, Category="Components|Activation", meta=(UnsafeDuringActorConstruction="true"))
ENGINE_API virtual void SetActive(bool bNewActive, bool bReset=false); Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| bNewActive | bool | Whether the component should become active (true) or inactive (false). | — |
| bReset | bool | If true and bNewActive is true, activate even if ShouldActivate() would return false. | false |
Return Type
void Example
Toggle based on game state C++
void AMyActor::SetRadarActive(bool bActive)
{
if (RadarComponent)
{
RadarComponent->SetActive(bActive);
}
} Tags
Version History
Introduced in: 4.0
| Version | Status | Notes |
|---|---|---|
| 5.6 | stable | — |
Feedback
Was this helpful?