Tick components when paused

Dear Mr. Answerhub,

I’m having a hard time understanding component ticking. I’ve made a pawn that is basically just a camera. It has three components: A dummy actor serving as the camera target, a UCameraComponent and a USpringArmComponent connecting the two. The components are all created in C++. I zoom the camera by altering the arm length, which works nicely.

The issue arises when I pause the game. I would like to be able to move/rotate/zoom the camera while paused, as seen in e.g. Baldur’s Gate, Dragon Age etc. So I set the flag bTickEvenWhenPause to true. The tick-function for the main actor then runs while paused.
Rotating and moving the camera works just fine, though the zoom ceases to work. A little investigation of the code for the USpringArmComponent uncovers that it calls UpdateDesiredArmLocation in its TickComponent-function so it’s no wonder it doesn’t get updated
if the tick-function isn’t called. I have “solved” the issue by calling the spring arm’s TickComponent-function manually from my pawn’s tick-function when the game is paused, though I suspect that this isn’t the intended way of dealing with component ticking.

What I would like to do is set the component’s tick behaviour to reflect that of its parent actor (e.g. if the actor ticks while pause, the component ticks while paused), or have a SetTickableWhenPaused-function for components similar to the one for actors.

There’s a promising function called SetupActorComponentTickFunction(struct FTickFunction* TickFunction) that in the “Remarks”-section states “I tick while paused if only if my owner does” (UActorComponent::SetupActorComponentTickFunction | Unreal Engine Documentation),
though I haven’t been able to make it work.

So if anybody has any insight on getting components to tick while paused, any help would be greatly appreciated.

1 Like

Well, you could derive from the component and then in your derived component class’s constructor you could set:

PrimaryComponentTick.bTickEvenWhenPaused = true;

It’s not ideal because you’ll have to replace your current component with your own derived one - but it should solve your problem.

1 Like

Or, quite possibly, you can get the FTickFunction from your component and do something like:

FTickFunction* TickFunction = Component->PrimaryComponentTick;
if( TickFunction)
{
    TickFunction->bTickEvenWhenPaused = true;
}

I haven’t tried it but looking at the headers, it seems like it should work. And at least doing it that way means you don’t have to derive from components!

Sir Neil! You are a gentleman and a scholar, that worked perfectly. Karma coming your way along with my gratitude.