In-game Clock and event triggers.

Hi,

I have been researching on how to go about creating a in game clock timer that goes faster than normal world time that will allow me to trigger events to happen at a certain time say at 8pm a sound plays (Im imagining I would do this by placing it into a function).

So far all I have found is creating time through ways such as using a timeline or by ticks but im finding it difficult to wrap my head round how I can control events/time this way. Can anyone point my in the right direction or suggest how I can tackle this problem?

Thanks :smiley:

I’d suggest decide how fast you want time to be going to have a class say game instance tick to a delay .5 for double speed… After each tick you add an int to int. For seconds.

After that a series of branches that look at the value of seconds. 60 is a “minute” 600 a hour etc.

14400being 24 hours… In the branches you ask is int = ## if yes call an event.

So far I’v managed to create some sort of event trigger at a certain time through the use of a timeline and setting variables for hours and minutes, then obviously if hours/minutes = event trigger time then play event. However im just curious if there was any other way of implementing a system like this apart from using ticks incase it may affect performance. It shouldn’t do but just wanted to learn :slight_smile:
Appreciate the response.

Are you trying to do clocks from games like GTA, Saints Row and etc that each hour in game is a minute in real life?

Well, you could use the Unreal vehicle example macro Timer, and do little modifications to make into a proper 12/24 hours time.

Now if you want something to happen in a specific time, like at 6pm a shower of meteor happens, I think you would have to use a Branch condition, if its 6pm, then play the animation (true), if its not, do nothing (false).

Highly advise against this unless you want to put yourself at risk of tying the clock speed to the framerate. If all you’re looking for is adding to a variable representing the overall time and then doing your calculation to get it into a 24-hour format, make a standard timer that works in realtime working first. To do that all you have to do is add to a variable in gamemode and make sure to multiply by Delta Time to avoid the clock speed changing based on the framerate. Then just make a separate variable to represent the time multiplier (in your case, 2.0) and just multiply using that variable before adding it to the time variable; that way you can use event triggers to change the multiplier variable whenever you want.