How to make timer variable to 3 decimal places

0 favourites
  • 5 posts
From the Asset Store
Easily store, modify, read and manipulate colors with Color Variables!
  • Good evening,

    Been hitting my head against the wall on this one. Here are the details:

    Trying to create a timer that I can round to 3 decimal places (3.456 seconds) and use that information to activate other events.

    When I created a global variable and made it increase 0.001 every 0.001 seconds, I found out in Debug Mode that the variable was becoming 0.0010000000003 or something like that which becomes an issue as I'm trying to have events activate at exactly (EQUAL TO) times.

    Is there a way to have my "time" global variable increase by 0.001 every 0.001 seconds and not further past that? Basically, how do I round off the value of my "time" global variable at 0.00X position?

    Tagged:

  • Use a calculation like round(seconds * 1000) / 1000

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Ashley,

    Where would you put that expression?

  • Wherever you display the number.

  • tonylarison

    it is normal for floating point numbers to have tiny variations like that, so rounding whenever you check the global variable is usually necessary.

    the event sheet runs at the games frame rate - normally 60 times a second under ideal conditions.

    that is every 0.0167 seconds. And there is no guarantee that each tick will happen at an exact interval.

    you have to use dt to know how long it has been since the last tick.

    looking for a specific time with that many decimals will not work.

    you can use timers, and other types of triggers to make things happen when required. What are you trying to do? there may be a better way that you haven't considered...

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