How do I: count time with precision (/an input of time passed)?
I've set up some simple logic to count time, but it's a bit off. I've used a counter, and it seems it does not update as fast as it needs.
I'm probably overlooking a better and/or simpler way to do it, so: how do I get a precise input of time passed?
Picture 1 is the logic for each time counter (picture 1-B shows the gadgets expanded). The setup is the following: the timer is set to reach determined limit. When it does, it adds that value to a variable initially set to zero, and resets itself.
I've made 3 of these, with max timer values of 0.1s, 0.2s and 1.0s, and compared the time counted by each with a the time shown directly by a timer (picture 2).
Pictures numered 3 are the results as time passed.
At the last picture 48.7s had passed, and the counters were showing, respectively, 36.5, 41.6, and 47.0.
Thanks!
-
Hi, you're suffering from the fact that the game updates 30 times a second (ie. 0.0333333.. s per frame) which is not a nice decimal update step.
A simple way to get a variable counting up time is to use a calculator and a variable modifier. You can set your calculator to give a result of 1 divided by 30 and wire that into a variable modifier's "Operation Value". Set the operation type to "Add" and set the Update Type to "Continuous". Every frame it will add 0.0333333...s to the variable which is exactly what you need!
Hope that helps.
Matt -
If you just literally want the current time passed, you can use a timer's current time value as an output.
If you'd like the timer to go on forever so it never stops itself, you can set the target time to something ahead of the current time. For example: timer's current time > calculator (current time + 1) > timer's target time.
댓글을 남기려면 로그인하세요.