Ignoring keyboard inputs for variables of time

0 favourites
  • 6 posts
From the Asset Store
An educational game for Times Table. An easy to use template for developers to build larger games
  • So I?ve finally gotten a hand on how make player characters perform combo attacks, but now I have a new problem. How do I make it so certain keyboard inputs are not allowed for a certain amount of time? I can ignore platform movement, but what about just regular ol? keyboard inputs?

    For example,

    Let?s say my attack button is X on the keyboard

    And for the sake of simplicity let?s say my first attack animation lasts for 2 seconds, how do I make it so if X is pressed in the 1st second, it?s ignored. But if it?s pressed in the 2nd second, it?s registered and it activates the 2nd part of the combo.

    Posting the capx up so you guys know what I?m talking about

    dropbox.com/s/twabtyp6867ai0b/Comboanimationtesting.capx

  • First, you didn't post a capx, but a caproj file.

    Second, I just have a variable (or array value or whatever) for each one. You could even tie them to private variables on your character. But have it work as a cooldown more or less.

    If attackhold = 0, on keyboard key pressed --> Do action, set attackhold to 1, wait 2.0 seconds, set attackhold to 0.

    That way, the conditions won't be true again until the cooldown is over. You could also get fancy and use either else or a separate event for when the attackhold variable is set to 1 for the game to do something else. You could even have a visual cue come up on screen as long as attackhold = 1. So pretty neat stuff.

  • I re-posted with the proper capx this time, could you modify it the way you describe in your post? 'cause I tried it myself and got varied results and I don't know what I'm doing wrong, other than you telling me to think in terms of cooldowns as opposed to ignoring inputs.

    Thanks for the help!

  • If attackhold = 0, on keyboard key pressed --> Do action, set attackhold to 1, wait 2.0 seconds, set attackhold to 0.

    K, I figured out what the problem is. This advice works, but only for a single attack animation. i.e character does one slash when the attack button is pressed. Thing is, im trying to make my character do more combo attacks, i.e pressing attack button 3 time quickly triggers 3 different attack animations, and what I need is that for a short period of time in between each animation where pressing the attack button again will trigger the next animation. I'm currently messing with the "wait" and "is playing" conditions, but if anyone already knows how to do this, their input will be much appreciated :)

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • CDAfree C-7

    You just use the same advice as above but you use more variables...

    I'm not sure exactly what you need but it sounds like you're looking to finish attack animations before the next one plays, but in quick succession. You would just set variables at either end of Is Playing and at the end of each animation, trigger the next one.

  • Would this work?

    give player timer behaviour

    on x pressed - (attack)

                   start timer "attack"

    on x pressed - timer duration > 1 - (perform combo)

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