Download

Component is not ticking inside the editor

Hi all,

I’m trying to get live updates of a custom actor of mine working in the editor. Since Actors can’t tick in the editor, I’ve added a component to the actor which should be able to to. This component’s tick function will then call the necessary things to live-update the actor. Inspired by the CableComponent example I have a component which looks like:

UCLASS()
class UUpdateComponent : public USceneComponent
{
  GENERATED_BODY()
public:
  UUpdateComponent(const FObjectInitializer& PCIP);
  void TickComponent(float DeltaTime, enum ELevelTick TickType, FActorComponentTickFunction *ThisTickFunction) override;
};
#include "UpdateComponent.h"

UUpdateComponent::UUpdateComponent (const FObjectInitializer& PCIP)
  : Super(PCIP)
{
  PrimaryComponentTick.bCanEverTick = true;
  bTickInEditor = true;
  bAutoActivate = true;
  //bAutoRegister = true;
  //PrimaryComponentTick.bStartWithTickEnabled = true;
  //PrimaryComponentTick.TickGroup = TG_PrePhysics;
  //SetMobility(EComponentMobility::Movable);
  //SetupActorComponentTickFunction(&PrimaryComponentTick);
}

void UUpdateComponent::TickComponent(float DeltaTime, enum ELevelTick TickType, FActorComponentTickFunction *ThisTickFunction)
{
  UE_LOG(MyLog, Log, TEXT("UUpdateComponent::TickComponent"));

  Super::TickComponent(DeltaTime, TickType, ThisTickFunction);

  //Here is where I will update the owning actor
  //GetAttachmentRootActor()->DoThing();
};

There’s some commented-out code in the constructor which I’ve been trying but none of it helped.

In the owning actor’s constructor, I do the following and nothing else:

root = PCIP.CreateDefaultSubobject<UUpdateComponent>(this, TEXT("Updater component"));
RootComponent = root;

I would expect that when I add one of these to the scene, I should see lots of “UUpdateComponent::TickComponent” beings logged to the output but instead I see none. If I go into Play-In-Editor mode I start seeing the updates but as soon as I drop back to normal editor mode, they stop. Strangely, at one point I had it working but I am now unable to reproduce it.

Given that I see ticks in the PIE mode, I believe that my tick function is correctly registered and I’ve set bTickInEditor. Does anyone have any idea what could be causing the tick not to be called or any way I can start to debug the problem?

Matt,
I was doing some procedural stuff and encountered a strange issue that was only solved by creating a new level and re-adding the Actor. I know it sounds silly but have you tried that? It didn’t have to do with ticking, but it was just one of those things that was working and magically stopped. And there was just no explanation for the change (to failure).

Hey JohnnyBeans78,

Thanks for the tip! In the end creating a new level inside the editor did not work to improve anything. However, I noticed that no other standard components were working either (like the CableComponent for example) and so I created a brand new project and reimported my plugin. This worked correctly and I started getting ticks occurring within the editor.

I have no idea why the component ticking stopped working but it’s certainly a little bit worrying how brittle the system is.

In my experience above, after It was fixed (by creating a new level) I never saw the issue again. It almost bothers me that it never happened again. If you reopen the project that isn’t ticking, does it still not tick? I’m sure the guys at Epic would be happy to take a look (if you wouldn’t mind them looking).

This is an old thread, but since I had the problem myself and solved it, it seems useful to post the answer here. In order to get components ticked in the editor, you have to enable the “Realtime” option of the editor viewport:
0cc2475cea5047765d454ef26100220139d08640.png

Thank you so much! I must have accidentally pressed Ctrl+R.