For some reason the length of the animation in the first coroutine is carried over to the second. The first animation (Load_Bow) goes for 1.5 seconds (or whatever units ‘length’ refers to), and the second animation (Draw_Bow) goes for 1 second.
As a result of this, the second animation repeats as it continues until the length of the first animation is complete. I do not know why my code is doing this and I’m assuming I’ve missed something pretty important about how co-routines work.
public IEnumerator LoadBow()
{
this.gameObject.GetComponent<Animation>().CrossFade("Load_Bow");
yield return new WaitForSeconds(this.gameObject.GetComponent<Animation>()["Load_Bow"].length);
aimStates = AimStates.Draw;
}
public IEnumerator DrawBow()
{
this.gameObject.GetComponent<Animation>().CrossFade("Draw_Bow");
yield return new WaitForSeconds(this.gameObject.GetComponent<Animation>()["Draw_Bow"].length);
aimStates = AimStates.Aim;
}
public void Aiming()
{
moveTarget.SetActive(false);
switch(aimStates)
{
case AimStates.Load:
StartCoroutine(LoadBow());
break;
case AimStates.Draw:
StartCoroutine(DrawBow());
break;