# sm.ai.getClosestVisibleTeamOpponent

Returns the character, with an opposing color, closest to the unit.

**Kind:** Function

**Environments:** Game

## Game

``` { .lua .api-signature }
sm.ai.getClosestVisibleTeamOpponent( unit, color )
```

[Open the full Game reference](../Game-Script-Environment/Static-Functions/sm.ai.md#getclosestvisibleteamopponent)

**Parameters:**

| Name | Type | Description |
| --- | --- | --- |
| `unit` | [Unit](../Game-Script-Environment/Userdata/Unit.md) | The unit. |
| `color` | [Color](../Game-Script-Environment/Userdata/Color.md) | The color. |

**Returns:**

| Type | Description |
| --- | --- |
| [Character](../Game-Script-Environment/Userdata/Character.md) | The character. |
