sm.pathfinder

Pathfinder

Constants:

Functions:

  • constrainPointToNavMesh
  • getPath
  • getRandomPoint
  • getSortedNodes
  • getWorldPath
  • traversableRaycast

  • 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:

    TypeNameDescription
    WorldworldThe world to look in.
    Vec3pointThe point.
    tableabilities?Table of actor abilities { canWalk=boolean, canSwim=boolean }. Defaults to all abilities.

    Returns:

    TypeDescription
    Vec3The modified point.

    sm.pathfinder.getPath(character, destination, groundPos?, abilities?, costs?)

    Server only

    Find a path

    Parameters:

    TypeNameDescription
    CharactercharacterThe character to find path for
    Vec3destinationThe path destination
    booleangroundPos?If the destination is ground level (ignored if nav mesh is used) (Defaults to true)
    tableabilities?Table of actor abilities { canWalk=boolean, canSwim=boolean }. Defaults to character abilities.
    tablecosts?Table of traverse area costs [1-10] { ground=number, water=number, chemicals=number, oil=number, lava=number }. Defaults to default costs.

    Returns:

    TypeDescription
    tableThe 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:

    TypeNameDescription
    WorldworldThe world to look in.
    Vec3pointThe point.
    numberradiusThe radius to search in.
    tableabilities?Table of actor abilities { canWalk=boolean, canSwim=boolean }. Defaults to all abilities.

    Returns:

    TypeDescription
    Vec3The new random point. (returns original point in case of failure)

    sm.pathfinder.getSortedNodes(worldPosition, minDist, maxDist)

    Server only

    Find all nearby path nodes

    Parameters:

    TypeNameDescription
    Vec3worldPositionThe position to look in
    numberminDistMinimum distance around pos
    numbermaxDistMaximum distance around pos

    Returns:

    TypeDescription
    tableTable of PathNodes sorted closest to farthest

    sm.pathfinder.getWorldPath(world, start, destination, abilities?, costs?)

    Server only

    Find a path

    Parameters:

    TypeNameDescription
    WorldworldThe world to look in
    Vec3startThe path start
    Vec3destinationThe path destination
    tableabilities?Table of actor abilities { canWalk=boolean, canSwim=boolean }. Defaults to all abilities.
    tablecosts?Table of traverse area costs [1-10] { ground=number, water=number, chemicals=number, oil=number, lava=number }. Defaults to default costs.

    Returns:

    TypeDescription
    tableThe 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:

    TypeNameDescription
    WorldworldThe world to look in.
    Vec3startThe path start
    Vec3destinationThe path destination
    tableabilities?Table of actor abilities { canWalk=boolean, canSwim=boolean }. Defaults to all abilities.

    Returns:

    TypeDescription
    boolean,numberTrue if fully traversable, and a traversable distance when not fully traversable. (distance becomes FLT_MAX when fully traversable)