Difference between revisions of "LlGetClosestNavPoint"
Jump to navigation
Jump to search
m |
m |
||
(8 intermediate revisions by 5 users not shown) | |||
Line 1: | Line 1: | ||
{{ | {{LSL_Function | ||
|inject-2={{LSL_Function/position|point|region=*}} | |||
inject-2={{LSL_Function/position|point|region=*}}| | |func=llGetClosestNavPoint | ||
func=llGetClosestNavPoint| | |func_desc=Used to get a point on the navmesh that is the closest point to {{LSLP|point}}. | ||
func_desc=Used to get a point on the navmesh that is the closest point to | |func_sleep_frame=1 | ||
func_sleep_frame=1| | |return_type=list | ||
return_type=list| | |return_text=containing a single vector which is the closest point on the navmesh to the point provided or an empty list. | ||
return_text=containing a single vector which is the closest point on the navmesh to the point provided or an empty list.| | |func_footer=If an option is not explicitly set, the default value for that option is used. | ||
func_footer=If an option is not explicitly set, the default value for that option is used.| | |p1_type=vector|p1_name=point | ||
p1_type=vector| | |p2_type=list|p2_subtype=instructions|p2_name=options | ||
p1_name=point | |p2_desc=GCNP_* and other flags with their parameters. See [[#Options|options]] table | ||
|constants={{LSL Constants/llGetClosestNavPoint}} | |||
|caveats= | |||
* There is no guarantee that a path exists from your current location to the returned point. | |||
p2_name=options| | |examples= | ||
p2_desc=GCNP_* and other flags with their parameters. See [[#Options|options]] table| | <source lang="lsl2"> | ||
constants={{LSL Constants/llGetClosestNavPoint}}| | create_character() | ||
caveats= | { | ||
* There is no guarantee that a path exists from your current location to the returned point.| | // Clear any previous character behaviors | ||
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).| | llDeleteCharacter(); | ||
also_functions= | |||
// 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) ); | |||
} | |||
} | |||
</source> | |||
|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). | |||
|also_functions= | |||
* [[llCreateCharacter]] | * [[llCreateCharacter]] | ||
* [[llDeleteCharacter]] | * [[llDeleteCharacter]] | ||
Line 30: | Line 62: | ||
* [[llPursue]] | * [[llPursue]] | ||
* [[llUpdateCharacter]] | * [[llUpdateCharacter]] | ||
* [[llWanderWithin]]| | * [[llWanderWithin]] | ||
also_events= | |also_events= | ||
* [[path_update]] | * [[path_update]] | ||
|history = Date of Release [[ Release_Notes/Second_Life_Server/12#12.07.31.262785 | 31/07/2012 ]] | |||
|cat1=Pathfinding | |||
}} | }} |
Latest revision as of 01:45, 22 January 2015
LSL Portal | Functions | Events | Types | Operators | Constants | Flow Control | Script Library | Categorized Library | Tutorials |
Summary
Function: list llGetClosestNavPoint( vector point, list options );
Used to get a point on the navmesh that is the closest point to point.
Returns a list containing a single vector which is the closest point on the navmesh to the point provided or an empty list.
• vector | point | – | A point in region-local space | |
• list | options | – | GCNP_* and other flags with their parameters. See options table |
If an option is not explicitly set, the default value for that option is used.
Options | V | Parameters | Default | Description |
---|---|---|---|---|
[ GCNP_RADIUS ] | 0 | [ float distance ] | [ 20.0 ] | Limits how far out to search for a navigation point. |
[ GCNP_STATIC ] | 1 | [ 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. |
[ CHARACTER_TYPE ] | 6 | [ 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
- This function causes the script to sleep for 1 frame.
- 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).