What to use to count and store time in miliseconds?

I normally use just a set timer set to loop and set to 1 setting an integer to store in the seconds. But what to use so I can store in a float almost like a get world delta seconds. But where I can start and stop it as needed? Think a stopwatch.

Thanks all

Hey there @usa423! This video goes over a method, though it’s not my favorite implementation I’d recommend taking what you need for your implementation and working custom from there out.

Disclaimer: One or more of these links are unaffiliated with Epic Games. Epic Games is not liable for anything that may occur outside of this Unreal Engine domain. Please exercise your best judgment when following links outside of the forums.

1 Like

Thank you SE that is exactly what I needed!

For those out there that don’t have 30 minutes to watch the video I will try sum up and condense what he was saying.

He said that from what he has seen out there most tutorials about milisecond timers are doing it the wrong way and he claims those timers are inaccurate when compared to a real time stopwatch (which he has on his phone in the video). So his solution was to use a timeline. He claims a timer created using a timeline is more accurate in the miliseconds.

In your event graph right click and “add timeline’”. After the node is made double click to go into it.

Start by adding a float track, set the length to 999999 (in the video he mentioned if you needed more time just add more 9s). Add a keyframe, set the time to 0 and value to 0. Add a second keyframe, set the time to 999999, and the value to 999999. Compile, save, and close the timer window.

I appreciate that he found a way to use a timeline for this, and something to note while on the subject of timelines is that if you ever need fast firing event tick or even axis input like fire. You can just add a timeline and set the length and not even add a track and as soon as it activates out of its output node will come that fast fire.

I was needing a milisecond timer for setting up attack combos for my Beat Em Up template.

Add a Custom Event and name it “Start Milisecond Timer”. I plugged the red outputting node into “Play from start” as I want this to reset everytime it is called. In my player character I created a float that you could call counting variable or whatever. Off a character ref (which you could do just from a cast) SET this variable and drag out the float output from the timeline. Then in a branch check (from a GET of that variable) IF the number is less than whatever number you choose, and if it is, stop the timeline. The extra variable you see in the illustration was just for me to know how many reacts had happened to then trigger different punches and kicks. Although in this instance I may not have needed to stop the timer but I needed to essentially reset the other variable when not in that “window” so it made sense.

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.