Tick Alternative

Some things needs to be constantly updated (ex: Play time, Hit Points and Mana Points, Widget appearance, etc…). I usually use the Tick or a Timeline, but the timeline is not always available. Is there any alternatives that can help to improve performance so that there’s not so much running off the tick event?

I believe using a Delay node after the tick would do that, Would need profiling to tell.

HTH

Look into timers. They are a bit wonky to use, but can do exactly what you’re looking for and have more functionality to control them later.

Found a tutorial on Youtube that’s using them for functions and should give a little help with figuring them out.

1 Like

Timers can get quite unstable, they are referenced by text name, so if you change t hat name somewhere everything may get weird. Also all those places that you need change timer interval if you decide your tick needs be slower or faster.

Instead I am using custom event dispatcher, that i call “pulse”. I am placing it in player controller (its easy to get reference, and pulse is local to client in multiplayer, so no syncing). When pulse is ready i compare game time seconds to time when last pulse was called plus some delta time. I found out that calling pulse on 0.1 sec is plenty, and value when it starts to be visible is 0.3 sec.

I definitely like that idea! Seems much more efficient than people placing multiple tick events all over the place and you are essentially just dispatching your single tick event to everything that needs it, even if you had this running just on tick it would still be better than running multiple different tick events all over the place.

I’d rather use event based design for pretty much everything; if you take the time to polish your code you can make it all event based, even in blueprint graphs. Downside is it takes some more brain effort, more planning.
Unless I don’t care, then I use Tick, Timelines, Timers, loops or whatever…

I try and work with the same concepts, but when you need time based things to happen how do you manage it without a tick or timeline etc purely through events?

Wouldn’t this be a simpler version of what you’re doing? (i.e. call your event dispatcher where I’ve put the print string)

I do not trust timers, they were crashing my game quite badly (back in 4.4 or so).

And there is another reason: i use “game time seconds” this lets me pause game (by setting time dilatation) without worrying about all timers.

Ps. I just had idea to “transmit” time dilatation value and some boolean that tells everybody “it is time to pause” with pulse dispatcher. It goes to every actor that needs timed actions anyway.

Pps. There is one more trick to all this, but its quite advanced:

  • in addition to dispatcher create “pulse” interface, that is called by dispatcher and is used as middle man.
  • create blueprintable actor component, add pulse interface to it, and tell it to hook to your pulse dispatcher.
  • drop that component on any blueprint actor that needs pulse, and add pulse interface to it.
  • from actor component in dispatcher event, find owner, cast to pulse interface, and call that function as interface call, it should execute owner pulse function.

This way all you need to do is add pulse component and interface to blueprints that need pulse. No more additional pulse code in all blueprints, just drag component and use it. Yes it adds to code bloat, but its invisible to us, and actual blueprint graphs are much less messy.

Hourence uses timers extensively in Solus. He shows an interesting technique in one of his dev videos where he uses a random value for the timer Time input, so he can drop several blueprints into a level and they all update around the same time, but not all at the exact same time. I thought it was pretty clever.

Like already posted above, you can control game runtime within a single global loop firing fixed events, instead of ticking everything.

Yeah I knew that part but still using 1 tick event in there.

I will have to check out the Solus videos again, that does sound like a good idea of having the ticks slightly offset for a lot of things so that you aren’t smashing all the events at 1 go. Depends on your scale I suppose

For not ticking everything at once, you can send some integer counter value. (for eg looping from 0 to 9).
Then each event fires when that counter is equal to value stored in actor. (basically same as hourences idea for random interval).

It is kind of personal preferences, i just do not trust timers.