error CS1061: 'Animator' does not contain a definition for 'SetInt' and no accessible extension method 'SetInt'

so I'm having this error above in Unity and I don't know how to solve it.

The error from what I understand is in the switch, it's probably not getting the animator and blocking me from setting the animation value.

I searched on google and ended up not understanding very well, if anyone can help me I would appreciate it

   public class Pontos : MonoBehaviour
{
    public static Animator BluePoint, RedPoint;
    public static int Score;

    void Start()
    {
       BluePoint = GameObject.Find("Azul_Icons").GetComponent<Animator>();
       RedPoint = GameObject.Find("Vermelho_Icons").GetComponent<Animator>();

       Teste();
    }

    void Teste()
    {
        if (PlayerAzul.BlueShoot)
        {
            Score++;
        }
    }
}

public class Blue : Pontos
{
    void Point()
    {

        switch (Score)
        {
            case (0):
            BluePoint.SetInt("AzulValor", 0);
            Debug.Log("Score = 0");
            break;

            case (1):
            BluePoint.SetInt("AzulValor", 1);
            Debug.Log("Score = 1");
            break;

            case (2):
            BluePoint.SetInt("AzulValor", 2);
            Debug.Log("Score = 2");
            break;

            case (3):
            BluePoint.SetInt("AzulValor", 3);
            Debug.Log("Score = 3");
            break;
            
        }
    }
}

To give a better example, this code is my points table (it's not perfect because I'm still testing it).

In void Test, don't worry about "PlayerAzul" (class) and "BlueShoot" (bool) , they are from another script that is working fine.

1 answer

  • answered 2022-05-07 01:22 Chuck

    To expand on Retired Ninja's comment, you are not spelling it out fully. It's SetInteger, not SetInt.

How many English words
do you know?
Test your English vocabulary size, and measure
how many words do you know
Online Test
Powered by Examplum