Home > Software design >  Unity2D - Parameter does not exist, even though I've defined it
Unity2D - Parameter does not exist, even though I've defined it

Time:10-14

I've got two parameters in my animator, one called "horizontal" and one called "vertical." (see image below)

enter image description here

The "vertical" parameter works exactly as I'd like it to, but the "horizontal" one, despite using the same code, doesn't work. Here's my code snippet (I know it's kinda inefficient, I don't need feedback on that):

void Update()
    {
        x = Input.GetAxisRaw("Horizontal");
        y = Input.GetAxisRaw("Vertical");
        animcon.SetInteger("horizontal", Mathf.RoundToInt(x));
        animcon.SetInteger("vertical", Mathf.RoundToInt(y));
    }

and my error:

Parameter 'horizontal' does not exist.
UnityEngine.Animator:SetInteger (string,int)

AFAIK no spelling errors are present, but every other question like this is based around that solution.

CodePudding user response:

There was a space at the end of my var name, thanks @Milan Egon Votrubec!

  • Related