How to Enable Actor Instances to Process Blueprint Tick Events in the Editor

Sep 17, 2020.Knowledge
Originally written by Ryan B.

There may be times when you want a Blueprint based actor instance to tick in the editor.

There are two obstacles to overcome to achieve this.

  1. Actors don’t tick in the editor.
  2. Actor instances don’t process Blueprint events unless they are marked as “Call In Editor”.

To enable your actor to tick in the editor, you’ll need a native base class that inherits from AActor and FTickableGameObject. This will require you to override a few virtual functions, IsTickableInEditor and GetStatId. Your header should look something like this:

class MYPROJECT_API AMyActor : public AActor, public FTickableGameObject
            // Sets default values for this actor's properties
            // Called when the game starts or when spawned
            virtual void BeginPlay() override;
            // Called every frame
            virtual void Tick(float DeltaTime) override;
            bool IsTickableInEditor() const override { return true; }
            TStatId GetStatId() const override { return TStatId(); }

Your actor can now tick in the editor and the native tick function will work as expected. However, the Blueprint Tick event will not execute for the actor instance. By design, a Blueprint event must be marked as “CallInEditor” or processed by the ClassDefaultObject. Otherwise, the event won’t be executed in the editor. To get around this, you can temporarily set GAllowActorScriptExecutionInEditor to true right before your actor is ticked. Since we already overrode IsTickableInEditor, let’s set it there. Your IsTickableInEditor function should now look like this:

bool IsTickableInEditor() const override { GAllowActorScriptExecutionInEditor = true; return true; }

Now if you derive a Blueprint based actor from your native actor class, the Tick event in the Blueprint graph will execute.