MadaxMakesGames
MadaxMakesGames

Reputation: 19

error CS1023: Embedded statement cannot be a declaration or labeled statement

Not to good with coding but this is one of the first errors I have no idea how to fix lol. Trying to get my bullet to turn around 180 degrees when I press "a"

      void Update()
    {
        if (Input.GetKey("a"))

            Quaternion rotation = Quaternion.Euler(0, 0, 0);
        else
            Quaternion rotation = Quaternion.Euler(0, 180, 0);


    }

Upvotes: 0

Views: 189

Answers (1)

PMF
PMF

Reputation: 17248

A single-line statement cannot contain a declaration, since that would have a zero-scope. You are declaring a variable rotation that cannot be used anywhere, and therefore these statements are useless. What you probably mean to do is:

  void Update()
    {
        Quaternion rotation;
        if (Input.GetKey("a"))
            rotation = Quaternion.Euler(0, 0, 0);
        else
            rotation = Quaternion.Euler(0, 180, 0);
        // Do something with that quaternion

    }

Upvotes: 2

Related Questions