Basically I am creating an attack animation but I don’t want the player to be able to spam the attack button and attack very rapidly. So I “thought” the easiest way of fixing this issue is through an Coroutine … So I wrote this:
IEnumerator StartAttack()
{
yield return new WaitForSeconds(0.1666667f);
playerSprite.DoAnim(1);
}
very basic right? Looks like it should wait 0.16 seconds (time it takes for the attack animation to complete) but for some reason it doesn’t and I fail to realize why… I tried placing playerSprite.DoAnim(1); on the top and bottom of WaitForSeconds() but same results appear. Yes I did Initialize it in update()… Although probably could be that the wait time is to short? lol anyway any help will be very much appreciated. Thanks in advance
EDIT: I tried increasing the wait time and it looks as though it works at first but if you spam attack really fast it look like it breaks the coroutine or something? Idk… maybe my attacking skills are just to boss
FIXED! For anyone wondering basically the coroutine was being called to quickly since I was starting it in Update(). So I had to creating a bool that did a check to see if I was currently attacking Now I feel dumb…