How can I add a "cooldown" for a key press?

beckbbeckb Member Posts: 16
Currently a key press shoots a special kind of missile, but I only want to allow for this once every few seconds. How can that be done?

Comments

  • SearleSamaSearleSama Member Posts: 108
    edited April 2013
    simply add a boolean attribute that will toggle on when the key is pressed and a timer attribute countdown that starts also when the key is pressed after the countdown reaches zero have it toggle the boolean off.

    Then have a rule if boolean is off; when key is pressed; fire missile (also start timer and toggle boolean on).

    I hope that makes sense.
  • gyroscopegyroscope I am here.Member, Sous Chef, PRO Posts: 6,598
    edited April 2013

    Hi @beckb

    Yes, similar to what @SearleSama wrote...

    Something like:

    Rule: When key is down
    Rule: --- nested in above--- When ShotGo is false
    Change Attribute ShotGo to true
    Spawn missile
    Timer: After 2 seconds
    Change Attribute ShotGo to false

    ""You are in a maze of twisty passages, all alike." - Zork        temp domain http://spidergriffin.wix.com/alphaghostapps

Sign In or Register to comment.