Animator: Parameter does not exist
Parameter 'X' does not exist.
Your script set an Animator parameter by name, and the controller on that Animator has no parameter with that exact name. The call does nothing, so the animation never changes.
Read the Console line first
X is the name your code used. Open the controller in the Animator window and compare it with the Parameters tab, character for character.
Common causes
The parameter was never added
States and parameters are different things. A state named Run does not create a Run parameter; add it in the Parameters tab with the + button.
The case or spelling differs
isRunning is not IsRunning, and a trailing space in the parameter name makes it a different name.
The Animator uses a different controller
The script runs on an object whose Animator has another controller, or an Animator Override Controller built on one that lacks the parameter.
The fix
// Hash once, use everywhere: a typo fails in one place, and it is faster
private static readonly int IsRunning = Animator.StringToHash("IsRunning");
animator.SetBool(IsRunning, speed > 0.1f);Stop it coming back
Keep parameter names as hashed constants in one place, so they are typed once.
Questions
- How do I avoid typos in parameter names?
- Hash the name once and reuse it:
static readonly int Speed = Animator.StringToHash("Speed");thenanimator.SetFloat(Speed, value);. It is also faster than passing a string every frame. - Can I check whether a parameter exists at runtime?
- Loop over
animator.parametersand compare eachnameHash. This is useful for shared scripts used with several controllers. - I use an Animator Override Controller. Where do the parameters come from?
- An override controller only swaps animation clips. Its parameters, states and transitions come from the base controller it overrides, so add the parameter there.
Scripts that avoid it
Related errors
Got a different error? Paste it into the error lookup.