Hi! I’m trying to do a simple combat system where the player can hit the “A” key multiple times to perform a combo. The idea is to let the player do a 1, 2 or 3 hits combo by pressing “A”, “A-A” or “A-A-A” respectively. The character animation should stop after the first hit if only “A” is pressed, stop after the second hit if “A-A” is pressed and so on.
I have tried different ways to make this work using Mecanim triggers to determine which animation is being played and if it should move to the next one, but this method results clumsy and imprecise. I didn’t find any tutorial covering this topic… Can anybody help me?
Thank you so much for your help.
Not perfect but here’s some psuedocode to get you in the right direction:
public float akeypressed = 0;
public update(){
If(Input.GetKey(KeyCode.A)){
akeypressed +=1;
switch(akeypressed){
case 1:
//Level 1 of combo
break;
case 2:
//Level 2 of combo
break;
etc etc etc
}
}
startcoroutine("resetkeycount");
}
public ienumerator resetkeycount(){
yield return new waitforseconds(1);
akeypressed=0;
}
1 Like
So this would count how many time the A key is pressed in an interval of 1 sec and process the input so far?
Right, that is the basic concept, however as you get further into development you may have to change this to meet your specific needs. Remember to always plan for the future 
Thank you so much. I will try to implement it tomorrow.