UActorComponent::Activate
#include "Components/ActorComponent.h"
Access: public
Specifiers: virtualUFUNCTIONBlueprintCallable
Description
Activates the component if it is not already active (or if bReset is true). Sets bIsActive, fires OnComponentActivated, and allows the component to start ticking if configured to do so.
Caveats & Gotchas
- • Marked UnsafeDuringActorConstruction — do not call during the construction script phase in Blueprint or inside the C++ constructor. Doing so can leave the component in an inconsistent activation state before registration.
- • If bAutoActivate is true, Activate(false) is called automatically during component registration. You only need to call it manually for components that start inactive.
- • The default implementation calls ShouldActivate() and does nothing if it returns false and bReset is false. Override ShouldActivate() to control under what conditions the component can be activated.
Signature
UFUNCTION(BlueprintCallable, Category="Components|Activation", meta=(UnsafeDuringActorConstruction="true"))
ENGINE_API virtual void Activate(bool bReset=false); Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| bReset | bool | If true, activate even if ShouldActivate() returns false, forcing a reset of the component's active state. | false |
Return Type
void Example
Activate a component after delay C++
// In BeginPlay, defer activation until the world is loaded
void AMyActor::BeginPlay()
{
Super::BeginPlay();
// Start inactive, activate after 1 second
MyComponent->Deactivate();
FTimerHandle Handle;
GetWorldTimerManager().SetTimer(Handle, [this]()
{
MyComponent->Activate();
}, 1.0f, false);
} See Also
Tags
Version History
Introduced in: 4.0
| Version | Status | Notes |
|---|---|---|
| 5.6 | stable | — |
Feedback
Was this helpful?