# sm.ai.getClosestTree

Find the closest harvestable of 'tree' type in a world.

**Kind:** Function

**Environments:** Game

## Game

``` { .lua .api-signature }
sm.ai.getClosestTree( position, world? )
```

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

**Parameters:**

| Name | Type | Description |
| --- | --- | --- |
| `position` | [Vec3](../Game-Script-Environment/Userdata/Vec3.md) | The world position to search around. |
| `world` *(optional)* | [World](../Game-Script-Environment/Userdata/World.md) | The world to search in. (Defaults to the world of the script that is calling the function) |

**Returns:**

| Type | Description |
| --- | --- |
| [Harvestable](../Game-Script-Environment/Userdata/Harvestable.md) | The closest tree harvestable. |
