I am trying to make a skill button which will increase attack speed. I planned to do that by changing animator speed but these lines are not working whats my mistake here?
List<Animator> animators;
GameObject[] units;
void Start()
{
animators = new List<Animator>();
units = GameObject.FindGameObjectsWithTag("Player1");
for(int i = 0; i < units.Length; i++)
{
animators.Add(units[i].GetComponent<Animator>());
}
}
public void AttackSpeed()
{
for(int i = 0; i < units.Length; i++)
{
animators[i].speed = 2;
}
StartCoroutine("CountdownAttackSpeed");
}
IEnumerator CountdownAttackSpeed()
{
int counter = 4;
while (counter > 0)
{
yield return new WaitForSeconds(1);
counter--;
}
if (counter == 0)
{
for (int i = 0; i < units.Length; i++)
{
animators[i].speed = 1;
}
}
}