llGetClosestNavPoint
list llGetClosestNavPoint(vector point,// Position vector in region-local coordinates.list options// A list of GCNP_* flags and parameters to configure the search limits.
);- Returns
list- Energy
- 10
Used to get a point on the navmesh that is the closest point to point.
If an option is not explicitly set, the default value for that option is used.
Returns a list containing a single vector which is the closest point on the navmesh to the point provided or an empty list.
list result = llGetClosestNavPoint(ZERO_VECTOR, []);Specification
Section titled “Specification”CHARACTER_TYPE // Specifies the preferred surface and terrain terrain-type for the character (default is CHARACTER_TYPE_NONE).GCNP_RADIUS // Used with llGetClosestNavPoint to limit how far out to search for a navigation point.GCNP_STATIC // Used with llGetClosestNavPoint to specify that the test should use the static navmesh, ignoring all dynamic obstacles.
| Constant | Type | Value | Description |
|---|---|---|---|
GCNP_RADIUS | integer | 0 | Limits how far out to search for a navigation point. |
GCNP_STATIC | integer | 1 | 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 | 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
Section titled “Caveats”- There is no guarantee that a path exists from your current location to the returned point.
Examples
Section titled “Examples”Example 1
23 collapsed lines
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))6 collapsed lines
return;
llSay(0, "current position " + (string)currentPos + " and closest nav point " + (string)llList2Vector(points, 0) ); }}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).
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.