Is there a problem with "every x miliseconds"

This forum is currently in read-only mode.
  • Hi all

    I wanted to make smth like this.

    -----------------------

    If Player press "e" and Variable.e = 0 than

    set speed = 500

    Variable.e = 1

    -----------------------

    If variable.e = 1 than

    every 4000 miliseconds

    Variable.e = 0

    -----------------------

    If variable.e = 0 than

    set speed = 200

    -----------------------

    Which I just wanted to make is 4 second boost.

    First Problem : On first e press, Variable.e doesn't turn to 1. On second press it sometimes turns to 1, after that it returns to normal.

    Second Problem : When it turns to 1, it should return to 0 exactly 4 seconds later. But it sometimes turns to 0 after 1 second or 2 seconds or even 0,5 second and sometimes after 4 seconds.

    Whats going on ?

    It's like, it doesn't start to count from 0 to 4000 when I press to e. It's like, it starts to count on layout start, and on e press It's a luck to catch it on 0 , sometimes you may catch it on 3500. So after 500 miliseconds, it reaches to 4000 , so condition becomes true and variable.e turns to 0.

    I hope I could explain my problem.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • It starts at the value you give it, just as you would if you were to count to yourself while looking at your watch. Like you wouldn't start at zero would you?

    Try the function object's delay, or better yet use the timer behavior.

  • Thank you very much for your help..

    Actually I give a private variable to object. Than I used "every 1000 miliseconds" decrase that value 1, until it reaches to 0.

    I don't know if it makes exact 4 seconds from 4 to 0 but I guess It's more accurate than my first try.

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