Download

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.