- Home /
Get Animation states from an Animator in Unity3d
I've used Animator to create two animation states, I want to change the speed of these animations at run type. How can I get these animations at run time and change their speed? Do I have to attach Animation component or Animator is enough?
Comment
@simon Larsen I want to know which clip is playing each time, not just change the speed of all the animations
Answer by Looking4Game · Mar 31, 2014 at 07:34 AM
Hello, I use following code to add Destroy Handler Function into end of a clip realtime. Maybe It will help you to get clip information:
public bool f_AddDestroy() {
if (m_IsAddedDestroy)
return false;
AnimationInfo[] t_animInfo = m_SpriteX.m_Animator.GetCurrentAnimationClipState(0);
if (t_animInfo.Length > 0) {
AnimationClip t_clip = t_animInfo[0].clip;
AnimationEvent t_animEvent = new AnimationEvent();
t_animEvent.functionName = "f_EffectDone";
t_animEvent.time = t_clip.length;
t_animInfo[0].clip.AddEvent(t_animEvent);
m_IsAddedDestroy = true;
return true;
}
return false;
}
Your answer
![](https://koobas.hobune.stream/wayback/20220613141542im_/https://answers.unity.com/themes/thub/images/avi.jpg)