Download

Game Loop Timing Control & Time Management in BPs

First thing I always done when attempting to code, some call it more of a mutilation of code but still…
first thing was always to setup a game loop with timing so you could control what fired & when.
(some things can fire every tick w/ no issues but some stuff should be tied to frame rates, because they can vary so much)(hope I explained that right)

But in BluePrints, just using tick (and/or other time related nodes or options) seems to run at different rates going from editor to a packaged game, and other devices and can cause some undesirable effects. Having a method to control when an event fired or time-controlled option like timelines etc is fired would help BP users a lot. (tied to frame rates (30-60 etc) or real time/ game time) Not sure how this would be implemented or I explained it correctly, but I feel there’s a need for this. Timing & Timers are always a major concern in any game and on any device.

For example: I want an object to move at the same controlled rate of speed, whether it’s running at 60, 90, or 120 frames per second.
This may not seem like a big deal but it is easier to achieve in code and a lot more complex & confusing to someone doing BPs and especially someone new to BPs.

2nd note: BPs could use a simple Timer node with options for rate (real or gametime). one with just output pin & another with input/output or some way to control when it’s fired off. Like plug n play. :slight_smile:
(again, too new to UE4, to probably explain this correctly)

and on a 3rd note: concerning ‘Timespan’ , having an option to control what is displayed or used, whether hours:minutes:seconds would be a nice option. either in the timespan itself or when linked to text.

ps: still looking for an ‘auto-detect settings’ (user’s resolution/graphics settings) & ‘adjustable graphics settings slider’ nodes, lol. BP-er’s are so lazy.
(disclaimer: if I missed something or over-looked how to handle all this, feel free to comment & let me know) BPs need LUV ! :cool:

Hi ayretek,

Have a look at blueprint “Timer” nodes, they are already available in the editor and can be used to determine more specific timeframes as opposed to using tick.

thx adam for the reply

I was trying to set up a timer in UMG is part of the reason I mentioned it here, using timing events in UE4 seems to create erratic behaviors between different systems. Sometimes even between the editor & a packaged game. It seems you have to create a huge process just to set up a timer for different situations, instead of just using a node to get a timer (w/options). And this seems to present a whole new challenge inside of UMG.

My recent personal scenario was trying to fire off a countdown timer (from 5, 10, 15 mins) inside of an UMG HUD, being new to UE it seemed a horrid experience just to set up a simple timer. Within UMG using a text variable to setup & run a timer in, I tried looking / searching thru docs and web but not much info or they had incomplete references on the subject of timers. And I just thought how much easier it would have been to have had a timer, with drop down options to set type of time, game or real (enough control to achieve the same results over multiple devices), whether hours, mins, seconds, whether increment or decrement and fire when you wanted it to. Don’t know if timelines, timers actually work well from within UMG, didn’t test mostly because of the erratic behaviors I’ve experienced in them so far, even trying to use gametime /realtime w/ timespans or alone, they continuously fire off (as they should) and are hard to use between different game situations because they update all the time.

This comes from just my personal experiences with UE and I could imagine how others, especially ones new to the engine would get frustrated over setting up a simple timer, and even on success being unhappy with the final results once inside a built game.
I realize that BluePrints in most engine users eyes is just for prototyping but after using BPs for a short time, I can see the power within them, especially for small projects or games. It’s utility is underestimated in my opinion and having simplicity of use could help make it excel as a viable game creation system in itself.

Thanks for taking the time to consider my suggestions. :slight_smile:

Hi ayretek,

What you should be able to do is create the timer then create a custom event with the name of the event being the name of the “Function” input on your timer. Put whatever functionality you want from this together then you should be able to call the custom event as a function from then on. You can see what I mean in the image below:

&d=1417026569

well thx adam, for some odd reason that just clicked off in me lil’ brain.

I’ve looked at a lot of examples & docs and it never clicked, I will try this out in my bloated char BP & then use the event in UMG and see how it works. If I’d seen or realized that you could create the function itself from set timer would’ve helped, one gets so flustered when setting up BPs then tunnel vision sets in. :wink:

So I can just set this up with to fire off every second within my UMG HUD without much overhead or cost? (already use events to stay away from ticks as much as possible)
And would this run consistently across several different devices / machines?

again thx, was like a light bulb going off, actually more like a spotlight, lol

This should definitely work consistently as it isn’t dependent on framerate but on whatever timeframe you give it. Now of course if your game hits a lag spike or some other error it may be negatively impacted, but simply between two different machines it should be the same across the board.

of note:
(in case of someone’s searches leads to this)

‘Set Timer’ expects an explicit name in ‘Function Name’ field
ie: used a dispatcher to create the event and had to append the ‘_Event’ at the end for the ‘Function Name’ , engine doesn’t take this into consideration for you.

and altho, I’m using this method to deal with this for now, I still believe my suggestions are viable & should be taken into consideration for future consumption

Separately: Unreal Engine does not use a fixed time step for simulation. If you’re coding up your own integrator, and it is sensitive to time step size change (like most first-order integrators are,) then it will not be stable for you. UE does this beacuse it runs one physics step per display frame step. It can sub-step if frame time is long, although the sub-steps are then of an arbitrary length.