How do I create a cooldown between jumping?

0 favourites
  • 4 posts
From the Asset Store
Awardkit
$5 USD
Create custom awards and achievement or use the many templates and create your own.
  • Hey dudes I'm currently working on a game using physics and I need to make a cooldown between jumps because currently if you spam the up arrow key you will literally just fly. The only thing I can think of is something like

    Global variable jumpCooldown = 0;

    keyboard, key is pressed -

    if (jumpCooldown = 0) {

    apply physics force etc..

    }

    keyboard, key is pressed - wait 0.1 seconds - set jumpCooldown = 1;

    wait 2 seconds - set jumpCooldown = 0;

    this is super flawed but the only thing i could really think of

    (When the up arrow is pressed it sets the jumpCooldown variable to 1 after 0.1 seconds and reverts to 0 after say 2 seconds. Then an if statement checks if the variable is equal to 0 and then applys the physics force to create the jump, if it equals 1 it does nothing.)) and im fine trying to learn how to script this if i have to

    I'd be super grateful for any help.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • That looks fine, although not sure why the short wait is required before setting the variable to 1? You could also use a timer instead of a wait.

  • if i script this how do I make it so my code is actually referencing the keyboard is pressed functions and stuff?

  • Do you mean the js scripting? Post questions in here : construct.net/en/forum/construct-3/scripting-51

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