AActor::Tick
#include "GameFramework/Actor.h"
Access: public
Specifiers: virtual
Description
Called every frame if `PrimaryActorTick.bCanEverTick` is set to true. Use this for per-frame updates. Prefer event-driven patterns over Tick where possible for performance.
Signature
virtual void Tick(float DeltaSeconds) Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| DeltaSeconds | float | Elapsed time in seconds since the last frame. | — |
Return Type
void Caveats & Gotchas
- • Tick is disabled by default. Set `PrimaryActorTick.bCanEverTick = true` in the constructor to enable it.
- • Always call `Super::Tick(DeltaSeconds)` to ensure base class tick logic and component ticking works.
- • Avoid expensive per-frame operations. Use timers (`GetWorldTimerManager().SetTimer()`) for lower-frequency logic.
- • Tick ordering between actors is not guaranteed unless you set `PrimaryActorTick.AddPrerequisite()`.
Example
Enabling and using Tick C++
// In constructor:
PrimaryActorTick.bCanEverTick = true;
// Override:
void AMyActor::Tick(float DeltaSeconds)
{
Super::Tick(DeltaSeconds);
// Move forward at 100 units/second
FVector NewLocation = GetActorLocation() + GetActorForwardVector() * 100.f * DeltaSeconds;
SetActorLocation(NewLocation);
} See Also
Tags
Version History
Introduced in: 1.0
| Version | Status | Notes |
|---|---|---|
| 5.6 | stable | — |
Feedback
Was this helpful?