How efficient is this algorithm?

Hello! after a couple of hours trying to make an timer that works with the game paused i was wondering how efficient is. It would make my game slow or cause any problems in long term?

Thank you!

*Almost forgot it, on the “Begin play” event i get a reference of the timeline called “Timer” and set it the length and “SetTickeableWhenPaused” to true.

It really depends what you’re doing on tick, but tick is usually best avoided unless it’s something you actually need to happen every frame.

If you want something to tick when paused, why not just use a SetTimerByEvent. The whole blueprint can tick when paused ( it’s in the overall details ). Then you can set the timer to a reasonable amount rather than having it every tick.

As i said, im trying to make an algorithm that works while the game is paused, unfortunately SetTimerByEvent stops when the game is paused, as far as i know.

I haven’t specifically tried it, but I’m assuming when you set an entire BP to tick when the game is paused, the encompasses everything inside that BP.

I tried it, doesn’t work. Does it work for you?..

Tick works, yeah. You (I) can’t run a timer of it, sadly. But if you tick, you can count.

Now I have specifically tried it. Setting the BP to tick when paused doesn’t work. But if you put this stuff in the controller or a widget, then it will.

Wouldn’t this work:

Besides that, if you worry about your paused game run one function slowly, you have much bigger issues than this :wink:

If you check that for the whole BP, it has no effect…

This blueprints ticks even though the rest of the game is paused. Is this not what we’re after here?

Ok, some sort of weird ‘special case’.

I’ve lost count of how many times I’ve typed ‘tock’ instead of ‘tick’. I think Epic should also have a tock node…

Hmm nice to know it works in a controller or a widget, thanks. But I need it to work specifically on an actor.

I know that blueprints are not efficient at all compared to C ++, but on the downside I want to try to optimize the algorithm as much as possible.

And thank you for the link!

Oh my concern is just because I’m a bit obsessed with efficiency, I don’t want the game to go smooth but in a menu there is a drop in fps. It would be a bit embarrassing.

And it dosent works with SetTimerByEvent, but thanks for your help!

I’m a bit obsessed with efficiency

  • use blueprints
  • be efficient

You get to choose only one. Can’t have both. :expressionless:

From my experience efficiency is getting something working first - that’s you being efficient. Refactor later - that’s making your code (a wee bit more) efficient. There’s no need to optimise something that is not there.

Also: Performance and Profiling | Unreal Engine Documentation

I don’t want the game to go smooth but
in a menu there is a drop in fps. It
would be a bit embarrassing.

I’m not sure I follow. Are you saying that this one function has a bigger performance hit than the actual game? Why - are you doing some heavy async lifting while paused?