GetCurrentAnimatorStateInfo(0).lenght not working
Hi!
I have a problem with the animator. I want to execute a clip when a previous one has finished. To do so I wrote this code:
anim1.SetTrigger("first_trigger"); print(anim1.GetCurrentAnimatorClipInfo(0).Length); yield return new WaitForSeconds(anim1.GetCurrentAnimatorStateInfo(0).length); anim2.SetTrigger("second_trigger");
The problem is that anim1.GetCurrentAnimatorStateInfo(0).length gets the length of the default clip, not the clip that is already playing. Do you know why?
Thank you very much!!! :D
Answer by charlesouimet · Nov 16, 2018 at 10:51 PM
This might be late but I ran into the same problem. Here is the solution : add a yield return new WaitForEndOfFrame(); before your wait for secondes. It worked for me. The debug now showed the right time to wait
yield return new WaitForEndOfFrame(); Debug.Log(anim.GetCurrentAnimatorStateInfo(0).length); yield return new WaitForSeconds(anim.GetCurrentAnimatorStateInfo(0).length);,Did you find the solution for this?? Currently running in the same problem at the moment
Your answer
![](https://koobas.hobune.stream/wayback/20220612154211im_/https://answers.unity.com/themes/thub/images/avi.jpg)