Weird Text bug

0 favourites
  • 7 posts
From the Asset Store
Change delay, create new lines, "backspace" the text
  • Hey,

    I've a pretty weird bug showed at the text object.

    I set the Text Object to - Health & " / " & Max_Health

    so it will show - 5 / 5

    The enemy's doing 0.1 Damage to the Player, so it should obviously show - 4.9 / 5

    But my Problem is, it shows really weird numbers, like - 4.9000000000000089 / 5 or something like that.

    I created a second Text object, what only shows the Health, and there it shows 4.9

    Does anyone have the same problem and knows a solution?

    Or is this a known bug?

    Kind regards

  • vendara - That's weird, I tried to remake your event and did not find anything wrong with the text object setting it's text to variables or variables have any problem. It must be the event you used to subtract the Health Variable or to put it simply, If there is a bug or an incorrect event then the problem must be when the enemy do some damage with the player.

    Try to use "Round" native expression to remove the decimal places when you cast damage. Are you using the "float" expression by any chance?

  • vendara - That's weird, I tried to remake your event and did not find anything wrong with the text object setting it's text to variables or variables have any problem. It must be the event you used to subtract the Health Variable or to put it simply, If there is a bug or an incorrect event then the problem must be when the enemy do some damage with the player.

    Try to use "Round" native expression to remove the decimal places when you cast damage. Are you using the "float" expression by any chance?

    There is nothing wrong with the events.

    I also tried to recreate it in a other Project, and it didn't happened.

    It even happens when I'm using floor or round, II already tried that.

  • > vendara - That's weird, I tried to remake your event and did not find anything wrong with the text object setting it's text to variables or variables have any problem. It must be the event you used to subtract the Health Variable or to put it simply, If there is a bug or an incorrect event then the problem must be when the enemy do some damage with the player.

    >

    > Try to use "Round" native expression to remove the decimal places when you cast damage. Are you using the "float" expression by any chance?

    >

    There is nothing wrong with the events.

    I also tried to recreate it in a other Project, and it didn't happened.

    It even happens when I'm using floor or round, II already tried that.

    It happened when you used round() too? That doesn't seem possible.

  • >

    > > vendara - That's weird, I tried to remake your event and did not find anything wrong with the text object setting it's text to variables or variables have any problem. It must be the event you used to subtract the Health Variable or to put it simply, If there is a bug or an incorrect event then the problem must be when the enemy do some damage with the player.

    > >

    > > Try to use "Round" native expression to remove the decimal places when you cast damage. Are you using the "float" expression by any chance?

    > >

    >

    > There is nothing wrong with the events.

    > I also tried to recreate it in a other Project, and it didn't happened.

    > It even happens when I'm using floor or round, II already tried that.

    >

    It happened when you used round() too? That doesn't seem possible.

    That's what i mean - weird bug

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Displaying floating point numbers can be troublesome in Javascript. The decimal part often doesn't have an absolute binary representation, which leads to your "weird" behavior. You should always format your numbers before displaying them when you are dealing with decimals. Too bad Construct doesn't offer expressions to deal with that. One way to do it would be to parse the string representation of your numbers, and limit the output to the wanted decimal places.

    Here's a crude example : https://dl.dropboxusercontent.com/u/700 ... ormat.capx

  • saw this is an old post but this is how you do it a simpler way

    for 2 decimals places: round(x * 100) / 100

    for 3 decimal places: round(x * 1000) / 1000

    etc..

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)