Ways to avoid a lot of ticking objects

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!

The first thing I’ll say is that you should probably not be worrying about this early in development. Time slicing or splitting your updates is only going to cause you headaches and it’s something you should avoid unless you really need it. Just calling an empty Tick function isn’t going to be that expensive. You’ll have the vtable lookup and that’s about it. You’d be much better off just finding the expensive Tick functions later in development and optimizing those.

That said, what you’ve described above is basically just the tick interval that’s already built into UE4.

Ok, will try something that I can do fast and check later if it’s performing good.

Thanks for your answer.

UE4 has a timer system built into it. Check out the WorldTimerManager. No need to create your own timers. Use the tick for things that happen on the tick, and use timers for things that require a timer.

Yeah thank you, did it this way now.