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" (https://docs.unrealengine.com/latest/INT/API/Runtime/Engine/Components/UActorComponent/SetupActorComponentTickFunction/index.html), 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.
asked Feb 03 '15 at 11:08 AM in C++ Programming
Well, you could derive from the component and then in your derived component class's constructor you could set:
It's not ideal because you'll have to replace your current component with your own derived one - but it should solve your problem.
Follow this question
Once you sign in you will be able to subscribe for any updates here