Set All bool parameters in animator to false

Hello human beings!

I want to set all the bool parameters in the animator of an object to false, to then be able to set only the one i want to true without needing to set each parameter prematurely in the editor.
I have tried doing that in many different ways but i can’t figure out how!

I don’t think my code will be any use but:

public Animator timeReflectionAnimator;
	public AnimatorControllerParameter[] parameters;

	private int posInList = 0;

foreach (AnimatorControllerParameter parameter in parameters) {
						if (parameter.type == AnimatorControllerParameterType.Bool) {
							timeReflectionAnimator.SetBool (parameter.name, false);
						}
					}
					timeReflectionAnimator.SetBool (animations[posInList].animation, true);

Don’t worry about the animations list. it’s a struct i made that gets a string and an int (animation, time).

Thank you for every help you can give!

Ethan

Hey @EitanCreate,

I think, this code should work:

foreach(AnimatorControllerParameter parameter in timeReflectionAnimator.parameters) {            
       timeReflectionAnimator.SetBool(parameter.name, false);            
}

Now you can set the one, that should be true, with:

timeReflectionAnimator.SetBool("yourParameterName", true);

funny, I had my solution with triggers first and thought I can translate it 1:1 to bools…

if you want to reset triggers you can use this code:

    void ResetAllAnimatorTriggers()
    {
        foreach (var trigger in MyAnimator.parameters)
        {
            if (trigger.type == AnimatorControllerParameterType.Trigger)
            {
                MyAnimator.ResetTrigger(trigger.name);
            }
        }
    }