Announcement

Collapse
No announcement yet.

Is there a way to convert seconds into minutes & seconds?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Is there a way to convert seconds into minutes & seconds?

    For example, I want my game to have a game clock like in basketball or football where you'd see the minutes and seconds left in the game......I don't want a timer that displays just seconds. Is there a way to convert seconds into a minute:seconds display?

    #2
    Are you looking for built-in functions? Because it's pretty simple math:

    Code:
    int32 minutes = totalSeconds / 60;
    int32 seconds = totalSeconds % 60;

    Comment


      #3
      Yeah I'm looking for built in functions.....something that's an accessible node in the blueprint graphs

      Comment


        #4
        You have % (mod) and division / nodes in blueprints so you can easily do that. There's no built in node like that already, it's too specific to be of any use, but you can create a macro or function node yourself for reuse.

        Comment


          #5
          You can build it yourself. The only tricky part is for it to display 12 min 7 sec as 12:07, instead of 12:7 because you cannot add a zero in front of an integer.

          For that you can convert the integer to string & add a '0' in front if the value is 9 or below.
          Check my working title: The Locked Room here: https://forums.unrealengine.com/show...he-locked-Room

          Comment


            #6
            Best way is to make a macro and then call it in the event graph.

            Click image for larger version

Name:	Untitled-1.jpg
Views:	1
Size:	443.6 KB
ID:	1058019

            Click image for larger version

Name:	Untitledw1.jpg
Views:	1
Size:	83.8 KB
ID:	1058020
            Last edited by soulmapp; 10-21-2014, 08:26 AM.
            RhinoGameHK | Twitter | Instagram

            Comment


              #7
              Setup is similar to what I have, expect I use Rama's Combine string function node.
              Check my working title: The Locked Room here: https://forums.unrealengine.com/show...he-locked-Room

              Comment


                #8
                Wanted to say after I looked high and low, I found soulmapp's method works. I set a timer in my Gamestate and for this widget I call the timer here. I made a slight adjustment to soulmapp's answer so the timer displays seconds as a double digit number such as 9:08 (9min 8sec) rather than 9:8.

                /necro_thread

                Comment


                  #9
                  Thank you very much, soulmapp!

                  Comment

                  Working...
                  X