How do I make an action happen after a button is held for a certain time

0 favourites
  • 4 posts
From the Asset Store
An educational game for Times Table. An easy to use template for developers to build larger games
  • I found a similar question, but implementing the answer didn't work for me. i read the timer documentation on here, but I'm probably still not understanding the timer correctly.

    I'm trying to pan the camera up and down with the up and down buttons, but only after they've been held for a short duration to avoid whipping the camera up and down on a momentary accidental hit of the button. I also want the camera to move back to its previous position when the button is released. In the secion "look up" I have implemented the solution I read on the forum, but it does not work and nothing happens when holding the button. The section "look down" is the previous, working implementation without a delay.

    Any ideas?

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • The problem isn't in the look up/down group, it's above it. The events in the look up/down should be working fine, but even if it is triggered, the events above (Camera MoveTo is Enabled / Player Is on Floor) will end up triggering the next tick anyways, meaning that it would "cancel" out the look up/down.

    Try this: add a global variable boolean called lookingUpOrDown (or whatever you want to call it) and set it to true on the On Timer events. Then, on the Camera MoveTo is Enabled and Player Is on Floor events, add a condition to check if lookingUpOrDown is false and only trigger if it is false. (Use System > Is Boolean Set, then right click on the condition and press Invert. This checks if the condition is NOT true.)

    Then on the W / S Released event, add Set lookingUpOrDown to false as an action.

    Hope this helps / works!

    EDIT: fixed a typo

  • Thank you so much! That worked perfectly :D toggling a global variable like this will help simplify some other stuff I'm working on too.

  • Glad I could help!

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