# sm.portal.findBestPortalToWorld

Finds the portal position that has the best path to the given world.

**Kind:** Function

**Environments:** Game

## Game

``` { .lua .api-signature }
sm.portal.findBestPortalToWorld( playerWorld, targetWorld, fromPosition )
```

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

**Parameters:**

| Name | Type | Description |
| --- | --- | --- |
| `playerWorld` | integer | The player's current world id. |
| `targetWorld` | integer | The world id we wanna get a path towards. |
| `fromPosition` | [Vec3](../Game-Script-Environment/Userdata/Vec3.md) | The position we wanna get a path from. |

**Returns:**

| Type | Description |
| --- | --- |
| [Vec3](../Game-Script-Environment/Userdata/Vec3.md)<br>[Portal](../Game-Script-Environment/Userdata/Portal.md) | The position of the portal, and the portal with the shortest path to the given world. |
