Anyone have an idea how to set the gametime to a 00:00:00 format
Basically i want it to be 00:01:08 indicating 1 minute 8 seconds.
Right now it outputs as 1.8
I tried various ways of doing this but none of them does what i want.
The only solution i do have is a very long a tedious and unpractical way of comparing every second.
Compare INT if equal to 1 set String to 01, If INT 2 Set String to 02 etc.
Im sure there is an easier way. Just haven’t found it yet.
My HUD is configured to print it correctly. I just need the correct format
You can get the seconds by using Modulo. In code you would use the % sign.
float seconds = GameTimeInSeconds % 60; // 60 because there are 60 seconds in a minute
The way it works is it will remove 60 (or whatever you use) from GameTimeInSeconds until there’s less then 60 left. It will then return whatever is left. In this case you remove one minute at a time until there’s less then a minute left, and the result is the remaining seconds.
You get the minutes by dividing by 60 and flooring the value.
You get the hours by dividing by (6060) which is 3600, and flooring the value.
You can get days by dividing by (6060*24) and flooring the value.
If you only need (minutes:seconds:milliseconds), I have created a custom actor component that will output this format automatically. Simply add the component to any blueprint you want and call the function. Everything else is taken care of under the hood. Code is all “copy/paste” to be blueprint user friendly. If you need hours as well feel free to modify the code, it shouldn’t be too difficult.