sm.pathfinder
Pathfinder
Constants:
Functions:
sm.pathfinder.conditionProperty
Condition link types
| height |
| target |
| none |
sm.pathfinder.constrainPointToNavMesh(world, point, abilities?)
Server only
Constrain a point to nav mesh. Returns original point if no nav mesh is found.
Parameters:
| Type | Name | Description |
|---|---|---|
| World | world | The world to look in. |
| Vec3 | point | The point. |
| table | abilities? | Table of actor abilities { canWalk=boolean, canSwim=boolean }. Defaults to all abilities. |
Returns:
| Type | Description |
|---|---|
| Vec3 | The modified point. |
sm.pathfinder.getPath(character, destination, groundPos?, abilities?, costs?)
Server only
Find a path
Parameters:
| Type | Name | Description |
|---|---|---|
| Character | character | The character to find path for |
| Vec3 | destination | The path destination |
| boolean | groundPos? | If the destination is ground level (ignored if nav mesh is used) (Defaults to true) |
| table | abilities? | Table of actor abilities { canWalk=boolean, canSwim=boolean }. Defaults to character abilities. |
| table | costs? | Table of traverse area costs [1-10] { ground=number, water=number, chemicals=number, oil=number, lava=number }. Defaults to default costs. |
Returns:
| Type | Description |
|---|---|
| table | The path as table of PathNodes |
sm.pathfinder.getRandomPoint(world, point, radius, abilities?)
Server only
Fetches a random point from the navmesh polys in a set radius. The point can be outside the radius but no polys outside the radius will be selected.
Parameters:
| Type | Name | Description |
|---|---|---|
| World | world | The world to look in. |
| Vec3 | point | The point. |
| number | radius | The radius to search in. |
| table | abilities? | Table of actor abilities { canWalk=boolean, canSwim=boolean }. Defaults to all abilities. |
Returns:
| Type | Description |
|---|---|
| Vec3 | The new random point. (returns original point in case of failure) |
sm.pathfinder.getSortedNodes(worldPosition, minDist, maxDist)
Server only
Find all nearby path nodes
Parameters:
| Type | Name | Description |
|---|---|---|
| Vec3 | worldPosition | The position to look in |
| number | minDist | Minimum distance around pos |
| number | maxDist | Maximum distance around pos |
Returns:
| Type | Description |
|---|---|
| table | Table of PathNodes sorted closest to farthest |
sm.pathfinder.getWorldPath(world, start, destination, abilities?, costs?)
Server only
Find a path
Parameters:
| Type | Name | Description |
|---|---|---|
| World | world | The world to look in |
| Vec3 | start | The path start |
| Vec3 | destination | The path destination |
| table | abilities? | Table of actor abilities { canWalk=boolean, canSwim=boolean }. Defaults to all abilities. |
| table | costs? | Table of traverse area costs [1-10] { ground=number, water=number, chemicals=number, oil=number, lava=number }. Defaults to default costs. |
Returns:
| Type | Description |
|---|---|
| table | The path as table of PathNodes |
sm.pathfinder.traversableRaycast(world, start, destination, abilities?)
Server only
Looks at the surface of the navmesh from the start position toward the destination position to see if it is traversable.
If the distance isn't fully traversable, the out_fDistance is the traversable distance.
Parameters:
| Type | Name | Description |
|---|---|---|
| World | world | The world to look in. |
| Vec3 | start | The path start |
| Vec3 | destination | The path destination |
| table | abilities? | Table of actor abilities { canWalk=boolean, canSwim=boolean }. Defaults to all abilities. |
Returns:
| Type | Description |
|---|---|
| boolean,number | True if fully traversable, and a traversable distance when not fully traversable. (distance becomes FLT_MAX when fully traversable) |