milliseconds

Hi everybody,

Can the timer use milliseconds?

Comments

  • adent42adent42 Key Master, Head Chef, Executive Chef, Member, PRO Posts: 3,051

    The timer is in seconds but you can request a fraction of a second. You can't request anything less that 16ms or 0.016 seconds as max framerate is 60fps. Depending on your game, the framerate can be lower, so I'd avoid requesting anything under 0.032 seconds in a timer.

  • krisztina.gross77krisztina.gross77 Member, BASIC Posts: 3

    thanks a lot!

    it works. But the timer is not in time. When I say Do after 15 seconds somethnig it beginns a little later. I need to make moovement very exactly in 0.25 seconds. is it possible?

  • adent42adent42 Key Master, Head Chef, Executive Chef, Member, PRO Posts: 3,051

    Due to the nature of our game engine, unfortunately it's not. It's probably off by 0.016-0.032 seconds but it could be slightly more. GameSalad isn't meant to be an engine with that much time accuracy, which is why we have the default unit in seconds instead of ms.

    My guess is what is happening is timer triggers to "true" in one frame and then executes its behaviors in the next frame. So if your game is intense, that next frame may be a bit off.

    Some ideas to help:

    • If possible, reduce what's happening in the game during the timer. This will ensure the frames don't take longer than than usual minimizing the time between the timer trigger and the behavior execution.
    • Subtract 0.032 to 0.05 seconds from your timer (so 0.2 instead of 0.25) which, while not exact, will help get it closer to the right value.
    • Depending on the game it might be more accurate to use a rule that looks at the game time rather than using the timer. I.e. when you want the timer to start store the current time + 0.25 seconds (I think game time is in ms, so i guess add 250 to the current game time). Then start a rule that will check the current game time against the timer. Once the current game time is greater than the stored time, you do what you need to the rule and set the game timer to 0 and turn off the timer behavior. In theory this should be similar to a timer, but when I last tested this method I got a bit better performance and accuracy.

    Hope those tips help!

Sign In or Register to comment.