Use a weak binding for delayed UObject work
The timer tracks the component weakly instead of keeping an unchecked raw this capture.
WeaponComponent.cppcpp
void UWeaponComponent::StartCooldown(const float DurationSeconds)
{
GetWorld()->GetTimerManager().SetTimer(
CooldownTimer,
FTimerDelegate::CreateWeakLambda(this, [this]()
{
bIsOnCooldown = false;
OnCooldownEnded.Broadcast();
}),
DurationSeconds,
false);
bIsOnCooldown = true;
}- Why
- If the component is destroyed before the timer fires, Unreal skips the callback instead of dereferencing freed memory.
- Costs
- The skipped callback is silent. If another system waits for completion, the owner still needs a cancellation path.
- Instead
- Use
BindUObjectfor a member function,CreateSPLambdafor a shared plain C++ owner, or an explicitTWeakObjectPtrcapture when the callback needs several objects.

