I made an alternative way to check for multible defenders in a square. It works fine but it looks a bit heavy in the if-sentence. My first thought was to minus _defender.transform.position with GetSquareClicked() but _defender.transform.position is a Vector3 and GetSquareClicked() is a return of a Vector2. Is there a elegant way to make convertions of Vectors?
private bool AlreadyOneInTheField()
{
bool oneMoreInTheField = false ;
foreach(Defender _defender in FindObjectsOfType<Defender>())
{
if (_defender.transform.position.x - GetSquareClicked().x == 0 && _defender.transform.position.y - GetSquareClicked().y == 0)
{
oneMoreInTheField = true;
}
}
return oneMoreInTheField;
}