Actor Tick in Editor

Hi,

Is there any special things to do to have a Actor set on the level to tick in Editor?

My actor have some parrellel task to exeute while in Editor, and I can’t check if the backgroundtask is done as the Tick is not called.

Thanks,

Do someone know at least if this is possible?

thanks,

Are you saying you only want the actor to tick if you’re in the editor?

Yes that’s exactly my needs.
Someone on the answer just told me it’s impossible. So I look to move my code in a Component that can tick in the editor only…
Just sad that we can’t control the actor in the same way.

Just put this in your constructor and make sure the blueprint default is to start with tick enabled. It absolutely does work



if (WITH_EDITOR)
{
	PrimaryActorTick.bCanEverTick = true;
	PrimaryActorTick.bStartWithTickEnabled = true;
}

Hi,

I already put:



PrimaryActorTick.bCanEverTick = true;
PrimaryActorTick.bStartWithTickEnabled = true;


in the class constructor and no tick function was called.

I will double check the BP defaults to see if the issue came from here.

Thanks,
Ps: Just to be sure, when you said ticking in the editor means ticking while editing the level and not PIE, right?

No, I meant ticking while PIE.

ok… so yes in PIE I can make it tick.

My needs is to have the actor ticking while editing. I think the path to go is the Component that can tick in Editor (as far as I read it… need to test it ^^).

I haven’t tried it, but I believe overriding AActor::ShouldTickIfViewportsOnly to return true should do what you’re after.

I confirm that ShouldTickIfViewportsOnly with return true did the trick!

Thanks,

1 Like

Can you tell me how you defined the override? I tried the following in my header file:



#pragma once

UCLASS()
class AProceduralStreetActor : public AActor
{
	GENERATED_BODY()

public:	
	AProceduralStreetActor(const FObjectInitializer& ObjectInitializer);

	virtual bool ShouldTickIfViewportsOnly() override;
};

And in my source file:

bool AProceduralStreetActor::ShouldTickIfViewportsOnly()
{
	return true;
}


But the compiler is telling me “‘AProceduralStreetActor::ShouldTickIfViewportsOnly’: method with override specifier ‘override’ did not override any base class methods”. But I can override
Tick and BeginPlay the same way? What am I doing wrong?

might be the const modifier that you missed:
virtual bool ShouldTickIfViewportsOnly() const override;

Thanks Evince, that was my fault.

I cannot seem to get this working in UE 5.1. The Editor acts like there is no Tick but works fine when in PIE.

void ACameraViewpoint::Tick(float DeltaTime)
{
#if WITH_EDITOR
	EditorTick(DeltaTime);
#endif
	
	Super::Tick(DeltaTime);
}

bool ACameraViewpoint::ShouldTickIfViewportsOnly() const
{
	return true;
}

Here’s a sample that’s working for me.

For the above question I might suggest making sure that ShouldTickIfViewportsOnly is declared correctly in the .h file like below for me. Otherwise I’d put a breakpoint in tick to see if it’s actually reaching your EditorTick function. Also, I don’t think it would matter much but convention is typically to put “Super” functions at the top of their derived function, maybe that’s screwing something up?

// In MyActorClass.h

public:

	// Allows us to draw debug shapes in the blueprint editor
	virtual bool ShouldTickIfViewportsOnly() const override
	{
		return true;
	}