So I’m making a game with different unit types moving about in formations, when the player controlled formation gets close to the enemy, it stops and projects an overlapsphere to check for tags - allowing it to see what type of unit it’s up against.
So ultimately I need to take the colliders from overlapsphere and return anywhere from one to three strings, detailing the enemy unit’s tags.
The problem is that overlapshere produces an array of colliders, and so I’m not sure how to return just one if that becomes an eventuality.
private string CheckEnemies()
{
Collider[] enemyColliders = Physics.OverlapSphere(unit.transform.position, combatRadius);
foreach (Collider col in enemyColliders)
{
string unitName = col.gameObject.tag;
}
return what?
}
C# doesn’t have the ability to return two data types to the best of my knowledge, so I’m not sure what to do here.