button press vs tap, combo attacks

so how do you do button press (hard) vs button tap (quick or light)?

the goal is to have a series of fast sword swings if tapping and a heavy swing if you press hard.

I was thinking something like

Update {
 if (button1) 
 set toggle
 add timer

if (toggle)
if (button1 == false)
end timer, do action
set toggle = false
}
Action{
if timer > 0.5 seconds doPress
if timer <= 0.5 seconds doTap
}

or something like that, basically checking the button each fram and if its pressed add to a timer, if not skip it, once the button is pushed once, youset a toggle or flag and remove it after the button is let go,. Then checking to see if the timer or counter was incremented past a half second or a quarter second. If you held the button down it would register as Press, if you barely tapped it it would register as a Tap.

Is there any tutorial or example or script for say Fighting game combos? I know you need amove array and a set of sequences you test against. Funky stuff. I was just hoping to have two attacks, a quick light attack and a heavy swing that was slow. Ideally, light tapping rapidly would do a three hit combo, linking from one animation clip to the next. Any clue on how to set this up?

Rather than processing checks every frame, it might be worth using the ButtonUp and ButtonDown functions from the Input class to capture your timing and determine if it was a tap or press.

I don’t know any good tutorials for this type of system, but what I would say (from having done something similar in the past) is to be careful how you process your input so as not to leave the player with obvious delays between pressing buttons and seeing results. One of the ways we went around this is to start the animation for the 1st button press regardless of whether it was a combo or not, then blend into a combo animation if required. So in the Tap and Press example, you start playing you animation for the Tap attack, then swap into the Press attack after confirming the button is down for the required time.

Of course this can have some animation implications, so it’s worth nailing this down before you get too far in :slight_smile: