два метода для входа и выхода из колизии.
void OnCollisionEnter2D(Collision2D col)
{
if (col.gameObject.tag == "Wood")
{
PlayerPrefs.SetFloat("Trees", trees);
isWood = true;
gm = col.gameObject;
if (isWood && isButtonE)
{
Destroy(col.gameObject);
isButtonE = false;
isWood = false;
trees++;
}
}
else if (col.gameObject.tag == "Apple")
{
objApple = col.gameObject;
Apples++;
Invoke("AppleDestroyable", 0.1f);
Destroy(objApple.gameObject);
}
else if (col.gameObject.tag == "Home")
{
PlayerPrefs.SetFloat("Timbers", timbers);
isHome = true;
if (isHome && isButtonE)
{
timbers++;
trees = trees - 1f;
PlayerPrefs.SetFloat("Timbers", timbers);
isButtonE = false;
isHome = false;
}
}
void OnCollisionExit2D(Collision2D col)
{
if (col.gameObject.tag == "Wood")
{
isWood = false;
}
else if (col.gameObject.tag == "Home")
{
isHome = false;
}
}
выдает ошибку: error CS0136: A local or parameter named 'col' cannot be declared in this scope because that name is used in an enclosing local scope to define a local or parameter