llNavigateTo
function
Function syntax
llNavigateTo(vector pos,// Destination position vector in region coordinates.list options// A list of parameters to configure pathfinding behavior (currently onlyFORCE_DIRECT_PATHis supported).
);- Energy
- 10
Directs an object to travel to a defined position in the region or adjacent regions.
Adjacent regions can be reached by extending the position vector into the nearby region.
llNavigateTo(ZERO_VECTOR, []);Specification
Section titled “Specification”FORCE_DIRECT_PATH // Forces the pathfinding character to navigate in a straight line toward the specified position (can be set to TRUE or FALSE).| Constant | Type | Value | Description |
|---|---|---|---|
FORCE_DIRECT_PATH | integer | 1 | Makes character navigate in a straight line toward pos. |
| Option | Value | Parameters | Default | Description |
|---|---|---|---|---|
| [ integer boolean ] | [ FALSE ] | Makes character navigate in a straight line toward pos. May be set to TRUE or FALSE. |
Caveats
Section titled “Caveats”- Must use
llCreateCharacterfirst or the function will fail with a viewer error. - Vertical positions specified for any vectors should be chosen to be as close as possible to the actual height of the surface requested. Large difference between the provided vertical position and the actual terrain/object will result in failure of the behavior.
- If you want to chase an agent or object as per the example below, it’s much more elegant and less sim resource intensive to use
llPursueinstead.
Examples
Section titled “Examples”Example 1
12 collapsed lines
vector last_touched_pos;key last_touched_key;
default{ state_entry() { llCreateCharacter([CHARACTER_DESIRED_SPEED, 50.0]); }
touch_start(integer total_number) { last_touched_key = llDetectedKey(0); last_touched_pos = llList2Vector(llGetObjectDetails(last_touched_key, [OBJECT_POS]), 0); llNavigateTo(last_touched_pos, []); llSetTimerEvent(0.2); }5 collapsed lines
timer() { vector last_touched_pos_now = llList2Vector(llGetObjectDetails(last_touched_key, [OBJECT_POS]), 0); if ( llVecDist(last_touched_pos_now, last_touched_pos) > 1 ) { last_touched_pos = last_touched_pos_now; llNavigateTo(last_touched_pos, []); } }}FORCE_DIRECT_PATHcan be used to rescue characters that have somehow fallen off the navigable zone as it doesn’t use the navmesh.
(Needs verification.)
- The position vector can be set outside the current region by using extended range region coordinates: e.g., to go to the SE corner of the region to the East of the current one, you could
llNavigateTo(<0.0, 512.0, 0.0>, []);
History
Section titled “History”Date of Release 31/07/2012
See also
Section titled “See also”Functions
Section titled “Functions”llCreateCharacterllDeleteCharacterllEvadellExecCharacterCmdllGetClosestNavPointllFleeFromllNavigateTollPatrolPointsllPursuellUpdateCharacterllWanderWithin
Events
Section titled “Events”Original wiki source
Some wiki templates and tables need their original context. View this article on the Second Life Wiki. Technical wording and examples are retained from the source; historical guidance may differ from current behavior.