Visual Studio – die besten Beiträge

Hallo ich habe ein Code in Unity wo es eine Fehlermeldung gibt die ich nicht verstehe. Könnt ihr mir helfen?

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;

    }

  }

}

C Sharp, Code, Programmiersprache, Visual Studio, Unity, unity 2d

mehrere Zahlen ausrechnen Windows Forms Taschenrechner?

Hallo,

Ich habe folgendes "Problem", habe meinen TR soweit hinbekommen, dass er Zahl 1 (+-*/) Zahl 2 ausrechnen kann. Nun soll ich Zahl 1 (+-*/) Zahl 2 (+-*/)Zahl 3,... ausrechnen können, stehe dabei leider irgendwie vor einer Wand und bekomme es nicht hin.

Hier der code: (etwas abgekürzt, da sonst zu lang)

Kopf=

Imports System.CodeDom
Public Class form1
  Public Property zahl As String = ""
  Public Property calc As String = ""

Bei alle Zahlen (0-9 sowie .)=

 Private Sub b1_Click(sender As Object, e As EventArgs) Handles b1.Click
    tb.Text += "1"
  End Sub

Delete Button=

 Private Sub bdel_Click(sender As Object, e As EventArgs) Handles bdel.Click
    If (tb.Text.Length > 0) Then
      tb.Text = tb.Text.Substring(0, tb.Text.Length - 1)
    End If
  End Sub
  End Sub

Gleich Button=

 Private Sub bsolve_Click(sender As Object, e As EventArgs) Handles bsolve.Click
    If (calc = "+") Then
      tb.Text = Val(zahl) + Val(tb.Text)
    End If
    If (calc = "-") Then
      tb.Text = Val(zahl) - Val(tb.Text)
    End If
    If (calc = "*") Then
      tb.Text = Val(zahl) * Val(tb.Text)
    End If
    If (calc = "/") Then
      tb.Text = Val(zahl) / Val(tb.Text)
    End If
  End Sub

bei allen Operatoren= (+,-,*,/)

Private Sub bplus_Click(sender As Object, e As EventArgs) Handles bplus.Click
    zahl = tb.Text
    calc = "+"
    tb.Text = ""
  End Sub

Vielen Dank schonmal

Visual Studio, Windows Forms

Meistgelesene Beiträge zum Thema Visual Studio