Timer instead of Tick
For anything that happens on a delay or a cooldown, use a timer rather than accumulating in Tick. It's cleaner and doesn't burn CPU every frame.
uclass ATimedActor : AActor meta: api=MYGAME_API
{
field public FTimerHandle CooldownHandle
func public void StartCooldown() BlueprintCallable
{
GetWorldTimerManager().SetTimer(CooldownHandle, this, &ATimedActor::OnCooldownDone, 2.0f, false);
}
func public void OnCooldownDone()
{
UE_LOG(LogTemp, Warning, TEXT("cooldown finished"));
}
}
SetTimer(handle, owner, &Delegate, rate, bLoop)- one-shot here (false).- Cancelling:
GetWorldTimerManager().ClearTimer(CooldownHandle); - Looping: pass
trueforbLoop.
Lambda variant
GetWorldTimerManager().SetTimer(CooldownHandle,
[this](){ UE_LOG(LogTemp, Warning, TEXT("done")); },
2.0f, false);
When to still use Tick
Use Tick only when something truly needs per-frame updates (continuous rotation, line traces while aiming, input smoothing). Otherwise prefer timers.