- Home /
Clear mecanim trigger input?
I have the problem that when I press accidently the dash key while jumping, the dashTrigger stays activated, thus after my jumping is complete I automatically dash. The same goes when I press the attack key or any other state I am calling with a trigger.
So my question is: Is there somehow a workaround to clear the input and not enable some combo-queue-behaviour?
Well...
In function Update I do stuff like this:
if(!isDashing && !isJumping && !isHanging && !isFalling) {
if (Input.GetButtonDown("DASH1"))
animator.SetTrigger("dashTrigger");
}
I don't see any problems with that
Answer by Nido · Sep 19, 2016 at 10:33 AM
Even it's an old post...
First and easier solution is having a bool to check if you finished the jump (via colliders, raycast, position...) and set the bool "jumping" to true when Input happens:
if (Input.GetButtonDown("DASH1") && !jumping)
{
animator.SetTrigger("dashTrigger");
jumping = true;
}
Or use the Animator.ResetTrigger a frame before the player touches the ground. https://docs.unity3d.com/ScriptReference/Animator.ResetTrigger.html