Can anyone offer an equation for calculating milliseconds (game is running at 60fps)? Also to calculate seconds and minutes? It seems like MMF only returns time in centiseconds (1/100)?
My format is 00:00:000 using 3 counters.
Cheers,
Reg
Can anyone offer an equation for calculating milliseconds (game is running at 60fps)? Also to calculate seconds and minutes? It seems like MMF only returns time in centiseconds (1/100)?
My format is 00:00:000 using 3 counters.
Cheers,
Reg
mmf can read 1000ths. the key word for retrieving the 1000ths in the expression editor is "timer"
also, the timer works independently of the fps.
you equation will be something like
return_seconds = (timer/1000) mod 60
return minutes = ((timer/1000)/60) mod 60
the "mod" just makes it go back to 0 after it counts higher than 59
Thanks for the equations. But I failed to mention I actually need the counter for milliseconds to constantly cycle from 0 to 1000.
Edit: I just realized that I need a way to handle pausing this timer, as there are moments in my game where the timer needs to be put on hold while events play out. I guess I need to manually record the time instead of using a constant game timer. Any suggestions?
After a lot of tinkering with the equations, I figured it out. For anyone else looking to use their own custom timer (add 1 to a variable every frame) and convert it to milliseconds, seconds and minutes you can use:
Always: Add 1 to "Time" variable
Milliseconds: Set Counter to Int(((1000.0/60.0)*Time) mod 1000)
Seconds: Set Counter to (Time/60) mod 60
Minutes: Set Counter to ((Time/60)/60) mod 60
Note: this is setup to work with the game running at 60fps. And just use Int((1000.0/60.0)*Time) if you want to retrieve the total milliseconds.
Excellent Mobichan, do you think that it can use as a replacement in order to Date & Time and set a countdown?
I ask this, because just this object is giving problems on 3 exporters: Android, IOS, and HTML5.
If you asked to give an example in MMF, I'd appreciate it greatly. I assume that by changing the variable TIME, you might have several clocks just as I have several Date & Time at the same time.![]()
Sorry Koji, but I am not at home to make an example. This method of calculating time would only be helpful if the game is running. If you need an internal clock that checks the current date or time even when the app is not running, this method won't help you. I would recommend using a server to give you the current time. But that would require the player always has an internet connection.
I might have time tonight to make an example. But you really only need to make a global variable called "Time" and 3 counters. Add 1 to Time every frame. Then set the counters to the equations I posted.
You're right Mobichan, it is too simple, the bad habit to ask for examples.![]()