LlGetClosestNavPoint
Looking for the current API? Open the llGetClosestNavPoint reference →
Wiki description
Used to get a point on the navmesh that is the closest point to
point.Function guidance
If an option is not explicitly set, the default value for that option is used.
Return value notes
Returns a list containing a single vector which is the closest point on the navmesh to the point provided or an empty list.
Specification
GCNP_RADIUS integer 0 b=[ e= ] s1=id="GCNP_RADIUS" nolink= c=Limits how far out to search for a navigation point.
GCNP_STATIC integer 1 b=[ e= ] s1=id="GCNP_STATIC" nolink= c=Specifies whether the test should use the static or dynamic nav mesh. In the static case, all dynamic obstacles are ignored.
CHARACTER_TYPE integer 6 b=[ e= ] s1=id="CHARACTER_TYPE" nolink= c=Filters nav points by eliminating nav mesh faces which are 0% walkable for the specified character type. In the default CHARACTER_TYPE_NONE case, all nav mesh faces are included.
| Options | V | Parameters | Default | Description |
|---|---|---|---|---|
| [ float distance ] | [ 20.0 ] | Limits how far out to search for a navigation point. | ||
| [ integer use_static_mesh ] | [ FALSE ] | Specifies whether the test should use the static or dynamic nav mesh. In the static case, all dynamic obstacles are ignored. | ||
| [ integer type ] | [ CHARACTER_TYPE_NONE ] | Filters nav points by eliminating nav mesh faces which are 0% walkable for the specified character type. In the default CHARACTER_TYPE_NONE case, all nav mesh faces are included. |
Caveats
- There is no guarantee that a path exists from your current location to the returned point.
Examples
create_character()
{
// Clear any previous character behaviors
llDeleteCharacter();
// default speed is 20
llCreateCharacter([CHARACTER_DESIRED_SPEED, 10.0]);
llWanderWithin(llGetPos(), <64.0, 64.0, 2.0>, []);
}
default
{
on_rez(integer start_param)
{
llResetScript();
}
state_entry()
{
create_character();
}
touch_start(integer num_detected)
{
vector currentPos = llGetPos();
list points = llGetClosestNavPoint(currentPos, [GCNP_RADIUS, 10.0] );
if (!llGetListLength(points))
return;
llSay(0, "current position " + (string)currentPos
+ " and closest nav point " + (string)llList2Vector(points, 0) );
}
}Notes
Using the method incurs a one frame script sleep and the call can be extremely expensive. It is intended to be used in response to a path_update message indicating an inability to reach a requested destination (e.g., because the character or the destination is off the mesh).
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.