Die Fehlermeldung lautet

Schweregrad Code Beschreibung Projekt Datei Zeile Unterdrückungszustand

Fehler CS1061 "Animation" enthält keine Definition für "SetBool", und es konnte keine zugängliche SetBool-Erweiterungsmethode gefunden werden, die ein erstes Argument vom Typ "Animation" akzeptiert (möglicherweise fehlt eine using-Direktive oder ein Assemblyverweis). Assembly-CSharp C:\Users\Me\2d platform\Assets\Player.cs 27 Aktiv

Der ganze Code ist

public class Player : MonoBehaviour

{

  public float speed = 5;

  private Rigidbody2D rb;

  public float jumph = 5;

  private bool ig =false;

  private Animation anim;

  // Start is called before the first frame update

  void Start()

  {

    rb = GetComponent<Rigidbody2D>();

    anim = GetComponent<Animation>();

  }

  // Update is called once per frame

  void Update()

  {

    float richtung = Input.GetAxis("Horizontal");

    if(richtung != 0)

    {

      anim.SetBool("IsRunning", true);

    }

    else

    {

      anim.SetBool("IsRunning", false);

    }

    transform.Translate(Vector2.right * speed * richtung * Time.deltaTime);

    if (Input.GetKeyDown(KeyCode.Space) && ig)

    {

      rb.AddForce(Vector2.up * jumph, ForceMode2D.Impulse);

      ig = false;

    }

  }

  private void OnCollisionEnter2D(Collision2D collision)

  {

    if(collision.gameObject.tag == "g")

    {

      ig = true;

    }

  }

}