Skip to content

Instantly share code, notes, and snippets.

@der-hugo
Created March 18, 2022 10:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save der-hugo/06b02044ed2907fa4f120acd27ccee90 to your computer and use it in GitHub Desktop.
Save der-hugo/06b02044ed2907fa4f120acd27ccee90 to your computer and use it in GitHub Desktop.
Reset all triggers of an Aniamtor -> attach this to the Basic Layer in order to automatically apply it to all states
using UnityEngine;
public class AnimatorTriggerResetter : StateMachineBehaviour
{
override public void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
{
foreach(var p in animator.parameters)
{
if (p.type == AnimatorControllerParameterType.Trigger)
{
animator.ResetTrigger(p.name);
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment