LlNavigateTo
Looking for the current API? Open the llNavigateTo reference →
Wiki description
Directs an object to travel to a defined position in the region or adjacent regions.
Function notes
Adjacent regions can be reached by extending the position vector into the nearby region.
Specification
| 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
- Must use llCreateCharacter first 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 llPursue instead.
Examples
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);
}
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, []);
}
}
}Notes
- FORCE_DIRECT_PATH can 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>, []);
See also: functions
See also: events
History
Date of Release 31/07/2012
Shared wiki helpers
The original page also injects shared parameter notes, caveats or issue information through these helpers. Their conditional MediaWiki logic is not reproduced here; inspect the preserved helper source for additional material.
Template:LSL Function/position
Original shared helper source (conditional wiki logic is not evaluated)
{{LSL Injection Test}}<noinclude>
This template is to be used to specify setup the description for position like parameters (offsets, positions, points, etc.).
Right now it's pretty basic and easy to edit. I'm wondering if these functions should be in a position parameter specific category.
====TODO====
* add clamping flag and verbiage for out of region/range coordinates.
</noinclude>{{#if:
{{#if:{{{region|}}}|
{{#if:{{{local|}}}|
{{#vardefine:p_{{{1|}}}_desc|position in {{HoverLink|Viewer coordinate frames#Region|Origin is the origin of the region which {{String|owns}} the object.|region}} or [[Viewer coordinate frames#Local|local coordinates]] depending upon the situation{{{desc|}}}}}
{{#vardefine:p_{{{1|}}}_hover|position in region or local coordinates depending upon the situation{{#if:{{{hover|}}}|{{{hover|}}}|{{{desc|}}}}}}}
|
{{#ifeq:{{{1|}}}|point|
{{#vardefine:p_{{{1|}}}_desc|A point in {{HoverLink|Viewer coordinate frames#Region|Origin is the origin of the region which {{String|owns}} the object.|region-local}} space{{#ifeq:{{{region|}}}|noZ| (z component is ignored)}}{{{desc|}}}}}
{{#vardefine:p_{{{1|}}}_hover|A point in region-local space{{#ifeq:{{{region|}}}|noZ| (z component is ignored)}}{{#if:{{{hover|}}}|{{{hover|}}}|{{{desc|}}}}}}}
|
{{#vardefine:p_{{{1|}}}_desc|position in {{HoverLink|Viewer coordinate frames#Region|Origin is the origin of the region which {{String|owns}} the object.|region coordinates}}{{#ifeq:{{{region|}}}|noZ| (z component is ignored)}}{{{desc|}}}}}
{{#vardefine:p_{{{1|}}}_hover|position in region coordinates{{#ifeq:{{{region|}}}|noZ| (z component is ignored)}}{{#if:{{{hover|}}}|{{{hover|}}}|{{{desc|}}}}}}}
}}
}}
|
{{#if:{{{local|}}}|
{{#ifeq:{{{1|}}}|offset|
{{LSL Function/offset|{{{1|}}}|local={{{local}}}}}
|
{{#vardefine:p_{{{1|}}}_desc|position in [[Viewer coordinate frames#Local|local coordinates]]{{{desc|}}}}}
{{#vardefine:p_{{{1|}}}_hover|position in local coordinates{{#if:{{{hover|}}}|{{{hover|}}}|{{{desc|}}}}}}}
}}
}}
}}
}}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.