Skip to content
This repository has been archived by the owner on Oct 19, 2020. It is now read-only.

Actors and components

pixeltris edited this page Jun 2, 2019 · 9 revisions

This briefly covers the basics of using AActor and UActorComponent

Enabling tick

The properties AActor.PrimaryActorTick / UActorComponent.PrimaryComponentTick are used to control the ticking functionality of actors and components. These properties are of type FTickFunction which is a struct (essentially a pointer to the C++ FTickFunction).

Enabling AActor tick:

public override void Initialize(FObjectInitializer initializer)
{
    base.Initialize(initializer);
    PrimaryActorTick.SetStartWithTickEnabled(true);
    PrimaryActorTick.SetCanEverTick(true);
}

Enabling UActorComponent tick:

public override void Initialize(FObjectInitializer initializer)
{
    base.Initialize(initializer);
    PrimaryComponentTick.SetStartWithTickEnabled(true);
    PrimaryComponentTick.SetCanEverTick(true);
}

It's best to enable tick in the Initialize function as the ticker is registered with the engine tickers just before the C# BeginPlay function is called. If you need to enable the ticker in BeginPlay you may need to manually register the ticker via FTickFunction.RegisterTickFunction.

Clone this wiki locally