I’m trying to use mecanim to chain combo animations together. My trouble is the counter that I assign in anim will always be 0, because Update() runs much faster than you can click the mouse to increase the counter. Is there a simple way to execute this every fifth update or so, or delay it so the counter can increase properly?
void Update(){
if(Input.GetButtonDown("Fire1")){
if (Mathf.Abs(Time.time - nextPunch) < 2){
switch(punch){
case 0:
//This is the first swing in the chain
punch = punch + 1;
nextPunch = Time.time + punchRate;
anim.SetFloat("Punch", punch);
break;
case 1:
//This is the second swing in the chain
punch = punch + 1;
nextPunch = Time.time + punchRate;
anim.SetFloat("Punch", punch);
break;
case 2:
//This is the last swing in the chain
punch = punch + 1;
nextPunch = Time.time + punchRate + punchDelay;
anim.SetFloat("Punch", punch);
break;
}
}
}
else {
punch = 0;
nextPunch = 0.0f;
}
}