Issues with animation controller

I’m using the animation controller for the first time.
I have a three step cycle that doesnt end in any dead ends. But for some reason, whenever i change a variable, the animation controller reverts to the default node, skipping the transition.

This is my relevant code

// Update the parameters only if they change
if (currentWalkingState != newWalkingState)
{
ModifyParameters(0, newWalkingState);
currentWalkingState = newWalkingState;
}

if (currentRunningState != newRunningState)
{
ModifyParameters(1, newRunningState);
currentRunningState = newRunningState;
}

public void ModifyParameters(int parameterIndex, bool state)
{
AnimatorControllerParameter parameters = controller.parameters;
parameters[parameterIndex].defaultBool = state;
controller.parameters = parameters;
}

Why does this happen, and how can i fix it??

You’re editing the default value for that animator, not the runtime values. Any changes to the animator defaults (like turning on FootIk or changing transitions) will reset the whole FSM. Do Animator.SetBool("IsRunning", value); instead. That said, the way this code currently works seems a little overly complicated. Why not create a BlendTree set to 1D on a new float parameter called Speed and then blend between the three different states with one variable?