Prevent Button Hold Down

Discussion in 'How Can I...?' started by sysads, Mar 31, 2017.

  1. sysads

    sysads Serious Boxer

    Joined:
    Oct 8, 2015
    Messages:
    885
    Likes Received:
    353
    I am searching everywhere if this had been answered in past but can't find it.

    Is it possible to prevent a character button from been pressed down too long?

    I just want them to tap the button one a time and not hold it down while it triggers character countinuosly.
     
  2. steverha

    steverha Boxer

    Joined:
    Oct 8, 2015
    Messages:
    49
    Likes Received:
    16
    If you set the timeout to .001, or whatever time you want, they would timeout and the button would deactivate even if they still hold it. But, they could also sit there and just spam the button every .5-1 seconds or so. I don't know what the button is used for, I imagine it's probably for an advanced move so one way around this would be to have the button as a powerup and make it so the button refills +1 or however many times you want it refilled whenever they pick up the action. It would require a lot regarding your level designs and timing, but it's do-able. I don't know what the button is for, but if its for say an extra jump in a platformer game, just make an action, set its timeout to .001-1 second, then the player only has that time frame to use the action before it times out. Let me know if this helps out at all, if not give me some more details and i'll see if I know of anything.
     
  3. sysads

    sysads Serious Boxer

    Joined:
    Oct 8, 2015
    Messages:
    885
    Likes Received:
    353
    Hi and thanks for the reply. This is what I am trying to achieve:

    - In the world UI, I have character button placed to cover the screen. The function is set to shoot. So when they tap the screen, it shoots an object.

    Now my challenge is, if you pressed down the screen, it starts shooting the object (not the character) and is not in sync with the sound that follows it because of the way I implemented it but if you tap tap tap, then its fine.

    So just wondering where I can set a timeout for the press down.
     
  4. brakewind723

    brakewind723 Serious Boxer

    Joined:
    Oct 3, 2015
    Messages:
    583
    Likes Received:
    506
    Best way to achieve this is give the bullet a wakeup of a distance like 600000000000 and drop the sound in the wakeup sound @sysads
     
  5. steverha

    steverha Boxer

    Joined:
    Oct 8, 2015
    Messages:
    49
    Likes Received:
    16
    Out of curiosity, does a wakeup distance of this proportion affect your game's performance at all?
     
  6. brakewind723

    brakewind723 Serious Boxer

    Joined:
    Oct 3, 2015
    Messages:
    583
    Likes Received:
    506
    Not that I'm aware of
     
  7. FranciscoBala

    FranciscoBala Avid Boxer

    Joined:
    Feb 25, 2017
    Messages:
    161
    Likes Received:
    72
    @brakewind723 Why "600000000000" and not another number? Is that regarding the area that the bullet is found within to 'wake up' and play sound ?
     
  8. brakewind723

    brakewind723 Serious Boxer

    Joined:
    Oct 3, 2015
    Messages:
    583
    Likes Received:
    506
    @FranciscoBala
    It honestly doesn't matter what number as long as the interger is large enough so when the object spawns (like a bullet) it will immediately wake up from any distance.
     
    FranciscoBala likes this.

Share This Page