How do I not trigger animation during play state of the triggered animation.
private void Update()
{
if(Input.GetMouseButtonUp(0))
{
animator.SetTrigger("AnimateTrigger");
}
}
When I press the left mouse button during the animation its runs it after the current one ends. Not sure how to stop this.
Comment
Answer by aditya007 · Apr 12, 2017 at 10:57 AM
You need to use AnimatorStateInfo for this. Use this to check whether the current animation is playing or not, and only trigger the animation if it is not already playing.
(Assuming your animation is on base layer)
private void Update()
{
AnimatorStateInfo animStateInfo;
animStateInfo = animator.GetCurrentAnimatorStateInfo(0);
if (!animStateInfo.IsName("Your_Animation_Name") && Input.GetMouseButtonUp(0))
{
animator.SetTrigger("AnimateTrigger");
}
}
Accept answer if it helps