Ways to avoid ticking components

Hey everyone,

current scenario: I make a production system and have to use any kind of timer for this (to produce after X seconds and to check every Y seconds if missing input goods are now there).

In the tick function I would most of the times just increase an ElapsedTime float and check like 2 or 3 bools and only every few seconds execute a “real”, consuming function.

I’m doing it in c++ so it is not that heavy as in BP, but still from what I have heard, ticking like up to 1000 components is performant. So here are my current ideas to do this:

  1. Make every component tick
  2. Give every component a looping timer that executes something like each second
  3. Register the components to some kind of controller, that has a looping timer for 1 second and notifies every registered component that a second is elapsed. Not sure if this is better, if you have like 500-1000 components to loop through.

So, which of these implementations is the best and do you have a better idea for this?

Would also be interested in some testing how many timers have a significant effect.

Thanks in advance!

Ok, so you would just give this component a TimerHandler that executes each second and use GetWorldTimerManager().SetTimer(…)?

Yes, that’s it.

Hi, there! Add Tick bodies only if smth should really happen every tick or very very often. For other periodic and delayed things you can use this FTimerManager | Unreal Engine Documentation. To keep performance high implement the most that you can with delegates and events.

Ok, thanks for the fast help, also for yesterday, somehow can’t write under that post