- Home /
playing one specific animation from animator controller
hi all,
i have downloaded a model from asset store. this model has amimator component with controller component. Controller component has many clips and play them respectively when i activate animator. i would like to play only one of them in case of situation, run, walk, jump etc. but i have not accomplished to play one specific clip although it prints all clips. the code share below not worked:
Animator anim = hero.GetComponent<Animator>();
RuntimeAnimatorController ac = anim.runtimeAnimatorController;
for(int i = 0; i<ac.animationClips.Length; i++) //For all animations
{
AnimationClip clip = ac.animationClips [i];
print (clip.name);
if(clip.name == "Walk") //If it has the same name as your clip
{
print ("play it...");
anim.Play("Walk");
}
}
when i activate animator it play my clip like this anim.Play("Walk"); but it continues playing other ones. i dont want it, i want it to stop after walking animation completed.
Answer by Santosh_Nair · Oct 13, 2018 at 03:53 PM
It is possible that the walk animation is connected to other animations given some condition or maybe on exit time. So once it is played, it goes to play the next animation. If it is so, then in your case, you should disconnect the animation from others. I.E inside the animator window, your walk animation should not be connected to others.
Answer by qobion · Oct 13, 2018 at 04:06 PM
Making your own Animator Controller is easier than you think. You know, you should read this article and then use commands like Animator.Play, Animator.SetTrigger, or Animator.SetBool
Answer by ysnky · Oct 14, 2018 at 12:23 PM
in fact i do not want to use state machine, animation controller.i want reach all clips and play by myself in case of situation via animation component. so i am trying to export clips from fbx but not allowed.
Your answer
Follow this Question
Related Questions
Is it possible to fire an event on every animation frame? 0 Answers
Set up Animator with specific seconds 1 Answer
Animator Controller using Animation Component? 0 Answers
How do I add the animation to my player in Unity 4? 1 Answer
Problem with character movement 2d when attaching animator 1 Answer