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.
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