I have script,that plays animations according to “tap” value.I wanted to wait for these animations to end before playing next so I have added yield,but it doesnt change anything.Here’s Script
void Update(){
timer = Time.timeSinceLevelLoad;
if (tap == 0){
anim.SetInteger ("Yatak",0);
}
if (Input.GetKeyDown (KeyCode.J)){
LastPress = Time.timeSinceLevelLoad;
if (tap > 2){
tap = 1;
}else{
tap++;
}
StartCoroutine(ComboJ());
}
if(timer - LastPress > 1){
tap = 0;
if(timer - LastPress < Atime){
attack = false;
}
}else{
attack = true;
}
}
IEnumerator ComboJ (){
if(attack){
switch (tap){
case 0:
anim.SetInteger("Yatak",0);
break;
case 1:
Atime = 1f;
anim.SetInteger("Yatak",1);
yield return new WaitForSeconds(1f);
break;
case 2:
Atime = 1f;
anim.SetInteger("Yatak",2);
yield return new WaitForSeconds(1f);
break;
case 3:
Atime = 0.35f;
anim.SetInteger("Yatak",3);
yield return new WaitForSeconds(0.35f);
break;
}
}
}