cooldown between punch

  • i have 2 types of punch

    running and idle

    both i press A button

    what i can do to add a little cooldown to prevent players to cancel the punch

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Create a timer that when is above a certain number allows you to punch.

    For example

    Variable punchTimer = 0

    Every Tick Add DT to punchTimer

    If punchTimer >= 4 and Button to Punch is pressed then

    Punch

    set punchTimer = 0

    Hope that makes sense.

  • LOL

    so Obvious

    why i didnt think about this

    thx a lot

  • It might be better to flip that around ArcadEd. In your example it would be the time since the previous attack that would determine what attack you could perform (rather than time since previous), and I believe he's actually trying to prevent canceling the punch.

    I would invert the meaning of your punchtimer like so:

    variable punchTimer = 0

    every Tick | subtract DT from punchTimer

    then actions are only allowed if the punchTimer = 0. You can even prevent changes in direction or other actions that would cancel the punch. In this way, different punch styles can set the punchTimer to different values, so you can have more time to recover from a running punch than a idle punch, for example.

    'Course, I could have also misunderstood what he wanted to do, too.

  • It might be better to flip that around ArcadEd. In your example it would be the time since the previous attack that would determine what attack you could perform (rather than time since previous), and I believe he's actually trying to prevent canceling the punch.

    I would invert the meaning of your punchtimer like so:

    variable punchTimer = 0

    every Tick | subtract DT from punchTimer

    then actions are only allowed if the punchTimer = 0. You can even prevent changes in direction or other actions that would cancel the punch. In this way, different punch styles can set the punchTimer to different values, so you can have more time to recover from a running punch than a idle punch, for example.

    'Course, I could have also misunderstood what he wanted to do, too.

    no no

    you got the point

    thx man

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