Skip to content
lsl.devlsl.devLSL Dev

Pathfinding

Pathfinding uses the region’s navmesh, a map of walkable surfaces built from the land and from objects marked as walkable or obstacles. Scripts can use it in two ways.

The light approach asks the navmesh for a path with llGetStaticPath and moves the object along it with keyframed motion or your own movement code. Active pathfinding turns the object into a character, a physics capsule the region steers.

Characters are limited in movement and physics, so the light approach often works better. Pathfinding is not a general game AI: for grid-based games or better paths, a script can run its own search.

Concepts

Functions and events

listllGetStaticPath(vector start_pos, vector end_pos, float radius, list params)
listllGetClosestNavPoint(vector point, list options)
voidllCreateCharacter(list options)
voidllUpdateCharacter(list options)
voidllDeleteCharacter()
voidllNavigateTo(vector pos, list options)
voidllPursue(key target, list options)
voidllExecCharacterCmd(integer command, list options)
eventpath_update(integer type, list reserved)

Static paths

The recommended approach: get waypoints from the static navmesh, then move with llSetKeyframedMotion or your own code.

Alternatives

For grid-based games or better paths, run your own search, such as A* over a grid, and test lines of sight with raycasts.

Scripting Details

listllGetStaticPath(vector start_pos, vector end_pos, float radius, list params)
Returns waypoints between two positions on the static navmesh for a character of the given radius; takes CHARACTER_TYPE in its params
listllGetClosestNavPoint(vector point, list options)
Returns the closest position on the navmesh to a point, or an empty list if none is found
voidllSetKeyframedMotion(list keyframes, list options)
Smoothly moves a non-physical object through positions, rotations and times; use it to follow a static path
voidllCreateCharacter(list options)
Converts the linkset into a pathfinding character, required to use the character functions
voidllUpdateCharacter(list options)
Updates the character’s settings
voidllDeleteCharacter()
Converts the linkset back to a standard physical object
voidllNavigateTo(vector pos, list options)
Navigates to a position in the current or adjacent regions
voidllPatrolPoints(list patrolPoints, list options)
Patrols through a list of points in order
voidllWanderWithin(vector origin, vector dist, list options)
Wanders around a central point within a bounding distance
voidllPursue(key target, list options)
Pursues a target, optionally intercepting it
voidllEvade(key target, list options)
Evades a target, hiding from it if a hiding spot is available
voidllFleeFrom(vector position, float distance, list options)
Keeps a given distance from a position
voidllExecCharacterCmd(integer command, list options)
Sends a command to the pathing system; currently only stopping or jumping
eventpath_update(integer type, list reserved)
Triggered on changes or failures in the character’s status, such as reaching the goal
eventmoving_start()
Triggered when the object starts moving
eventmoving_end()
Triggered when the object stops moving

Additional

Constant groups GetStaticPathParam 1GetClosestNavPointParam 3CharacterType 5CharacterParam 14CharacterAvoidanceMode 3CharacterOrientation 2CharacterTraversalType 3CharacterNavigateParam 1CharacterPatrolPointsParam 1CharacterWanderWithinParam 1CharacterPursueParam 5CharacterCommand 3CharacterPathUpdateType 13ObjectPathfindingType 8

For grid-based games or better paths, a script can run its own search, such as A* over a grid, and use raycasts to test lines of sight.

listllCastRay(vector start_pos, vector end_pos, list options)

See also Category PathfindingSL Wiki PathfindingSL Wiki LSL Pathfinding TypesFeature MovementFeature AnimeshFeature MathPlanned Recipe: following a static path with keyframed motionPlanned Recipe: A* search over a grid