The message says what it means: fields, properties and methods all have to be part of a class in C#, so you cannot declare them outside one.
What's happening is that you have a spurious close curly bracket immediately above the definition of
void OnDrawGizmosSelected()
which terminates the class definition. Remove it, or move it to the end of the actual class, and it'll probably work better.
If you check and maintain your indentation correctly, this kind of thing becomes a lot more obvious!
void Attack()
{
animator.SetTrigger("Attack");
Collider2D[] hitEnemies = Physics2D.OverlapCircleAll(attackPoint.position, attackRange, enemyLayers);
foreach(Collider2D enemy in hitEnemies)
{
Debug.Log("We hit" + enemy.name);
}
}
}
void OnDrawGizmosSelected()
{
Indent it, and it's more readable:
void Attack()
{
animator.SetTrigger("Attack");
Collider2D[] hitEnemies = Physics2D.OverlapCircleAll(attackPoint.position, attackRange, enemyLayers);
foreach(Collider2D enemy in hitEnemies)
{
Debug.Log("We hit" + enemy.name);
}
}
}
void OnDrawGizmosSelected()
{