Download

Difficulty appending variable of type float

Hi all,

I am using a timeline to count seconds. I am using the Seconds output pin from the timeline itself and I believe is coming out as a float. I want to format the second by adding a leading “0” if less than 10 seconds. I can’t seem to do any sort of appending to the float value using the append (string) where I add the 0 to the variable if less than 10. It doesn’t give me errors, and compiles fine, but the result simply ignores the top “A” box of the append box. I assume this is something to do with the timeline creating a float, and the append box looking to combine strings, and this breaks the functionality. What I have in a scaled down proof of concept blueprint:

Screenshot-3.jpg

So, is there a way to convert a float -> integer? I am counting to the nearest second so I don’t require the precision from the floats. Is there a way to tell the timeline to output as integer as compared to floats? I even tried the “to string” box to convert out of the timeline and then another “to integer” box to convert to an integer but it doesn’t work.

TLDR take your pick:

  • How do I successfully convert float to integer or string so I can append for HUD display?
  • How do I tell the timeline to output as integer or string out of the box so I can append for HUD display?

Thanks for reading
~ Matt

From what I understand, if the result is “9”, you want it to be “09”? Integers do not include preceding 0’s at the beginning, so it is automatically cut off when you add it. If you want to turn 9 into 90, swap the A & B on the append.

You should do this logic in the HUD display. The float variable can only store numbers without leading zeros. So the conversion of the string (from the Append) of “09” converted to a float (the node right before the ‘Set’ at the end) results in a 9 float variable.

You should move the logic that’s testing < 10 and what not over to your HUD area where you are displaying the value. So you will use the output of the ‘Append’ node as what you display rather than the float variable.