I have an error saying: (error CS0136: A local or parameter named 'facingRight' cannot be declared in this scope because that name is used in an enclosing local scope to define a local or parameter). I'm a kind of new to this so I don't know what it says and I haven't been able to find anything about it online. It would be nice if any of you could help me out here
I'm trying to make an animation flip in Unity, but I don't specifically remember what I've tried
bool facingRight = true;
bool facingLeft = false;
if (facingRight == true && facingLeft == false)
{
if (Input.GetKey("a"))
{
transform.localScale = new Vector3(-transform.localScale.x, transform.localScale.y, transform.localScale.z);
bool facingRight = true;
bool facingLeft = false;
}
}
if (facingLeft == true && facingRight == false)
{
if (Input.GetKey("a"))
{
transform.localScale = new Vector3(-transform.localScale.x, transform.localScale.y, transform.localScale.z);
bool facingLeft = true;
bool facingRight = false;
}
}
The expected result is for my animation to turn around when pressing the a key and then when pressing the d key it turns around again.