x

Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

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.

Isvulfe

Product Version: Not Selected
Tags:
more ▼

asked Feb 03 '15 at 11:08 AM in C++ Programming

avatar image

Isvulfe
160 9 10 18

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

1 answer: sort voted first

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.

more ▼

answered Feb 11 '15 at 05:31 PM

avatar image

Neil.Griffiths
353 14 15 28

avatar image Neil.Griffiths Feb 11 '15 at 05:34 PM

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!

avatar image Isvulfe Feb 11 '15 at 07:38 PM

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

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question