Ignore specific keypresses

0 favourites
  • 4 posts
  • Hi guys,

    Working on a top-down game that features characters interacting with various objects in the environment. I want to use three keys to trigger various actions, let's say "A" "S" and "F"

    While the action triggered by "A" is going on, I don't want the character to be able to do any potential actions triggered by "S" and "F" until the original action is completed.

    My question is: Can I selectively disable/enable input from a given key as an action, similar to the way 8-Direction behavior ignoring can be started/stopped? I don't see any mechanism for this, but I'm fairly new so I could be missing something.

    Any help is appreciated. Thanks!

  • Use something like this....Add extra conditions to your Initial conditions

    So..like add the condition and invert the extra conditions to get an opposite function

    Condition 1-> A is pressed

    Condition 2-> S is X Pressed (invert this to get the action..)

    etc etc..

    You can add as many conditions as you like to an Event and this included key presses ..

    To bring up the Extra condition menu..or if you need to invert them or place an 'OR" block just right click the starting Condition...Also keep in mind that conditions work best if they are Sequentially correct like a flow chart..

    So like ..If key A is pressed( the first check)

    & key S is not pressed etc...

    This is the basic idea..

    build up complex conditions for any situation you need...

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Makes perfect sense. Thanks!

  • Another way to do it, for fighting game example...

    If I my character is attacking, I set his   IsAttacking instance variable to 1. So for any button that I don't want to interrupt his attack's (like running, or another attack) , I do this...

    IsAttacking 0

    and SideAttack is pressed = > set IsAttacking to 1, play animation side attack,     

    so If i press the run button, it won't work while he's attacking.

    IsAttacking 0

    AND run is pressed. => Run

    Then I clean it up by...

    on Any Animation Finished = > Set IsAttacking to 0

    This way, animations can't interrupt him while he's attacking.

    Just another way to do things :)

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