In Mecanim, I have a couple trigger values that activate animations. I have a C# script reading the input, but when the mouse is clicked, for example, it may read in multiple clicks in one frame. This ends up activating the trigger twice in a row, making the animation glitchy. How do I prevent this from happening?
Here’s part of my code. As you can see, I even check to see if the animation is playing to prevent reading in multiple clicks, but I guess this doesn’t account for the transition time or something.
if(Input.GetKey(swing)) {
if(!anim.GetCurrentAnimatorStateInfo(0).IsName("Swing")) {
anim.SetTrigger("Swinging");
}
}