Difference between revisions of "LlWanderWithin"

From Second Life Wiki
Jump to navigation Jump to search
m
m (Added caveat)
 
(16 intermediate revisions by 7 users not shown)
Line 1: Line 1:
{{Pathfinding alpha}}
{{LSL_Function
{{LSL_Function|
|func=llWanderWithin
func=llWanderWithin|
|func_desc=Sets a character to wander about a central spot within a specified radius.
func_desc=Sets a character to wander about a central spot within a specified radius.|
|p1_type=vector|p1_name=origin|p1_desc=Central point to wander about
p1_type=vector|
|p2_type=vector|p2_name=dist|p2_desc=Sets how far the character may wander from {{LSLP|origin}}, along each world-aligned axis|p2_hover=Sets how far the character may wander from 'origin', along each world-aligned axis
p1_name=origin|
|p3_type=list|p3_subtype=instructions|p3_name=options|p3_desc=WANDER_* flags and their parameters
p1_desc=Central point to wander about.|
|constants={{LSL_Constants/llWanderWithin}}
p2_type=float|
|caveats=
p2_name=dist|
* Must use [[llCreateCharacter]] or script won't compile.
p2_desc=Sets how far the character may wander from ''origin''.|
* Wander area is a rough area based on the specified origin, to a specified scale on each axis. So, if <code><20, 10, 2></code> is specified the object will wander within 20m along the world x-axis, 10m along the world y-axis, and 2m along the world z-axis.
p3_type=list|
** if '''dist''' has any dimension less than 1.0, an error is shouted on [[DEBUG_CHANNEL]]. '''Scale too small. All dimensions must be at least 1.0.'''
p3_name=options|
* When [[WANDER_PAUSE_AT_WAYPOINTS]] is enabled, [[PU_GOAL_REACHED]] and [[PU_SLOWDOWN_DISTANCE_REACHED]] [[path_update]] events will be trigged when approaching each waypoint.  When this flag is disabled, the aforementioned path_update events will not be triggered when arriving at waypoints.
p3_desc=No options available at this time.|
caveats=
* Must use llCreateCharacter or script won't compile.
* Wander area is a rough area based on the specified origin, to a specified radius. So, if 10.0m is specified the object will wander within an area 20m to a side, centered on origin.
* Wander area can be limited to a smaller area by introducing obstacles such as walls.
* Wander area can be limited to a smaller area by introducing obstacles such as walls.
* Vertical positions specified for any vectors should be chosen to be as close as possible to the actual height of the terrain requested. Large difference between the provided vertical position and the actual terrain/object will result in failure of the behavior.
* Vertical positions specified for any vectors should be chosen to be as close as possible to the actual height of the terrain requested. Large difference between the provided vertical position and the actual terrain/object will result in failure of the behavior.
* As for all pathfinding behaviors, DO NOT rely on the detailed implementation here. The wander distance is just a rough estimate. We may change the exact shape on a whim. For fun. Or because it seems better that way. Or to ensure that you aren't relying on the detailed implementation. Don't make this another {{Jira|PATHBUG-69}}. :) |
* As for all pathfinding behaviors, DO NOT rely on the detailed implementation here. The wander distance is just a rough estimate. We may change the exact shape on a whim. For fun. Or because it seems better that way. Or to ensure that you aren't relying on the detailed implementation. Don't make this another {{Jira|PATHBUG-69}}. :)  
examples=
|examples=
<lsl>
<source lang="lsl2">
default
default
{
{
Line 30: Line 26:
     touch_start(integer total_number)
     touch_start(integer total_number)
     {
     {
         llWanderWithin(llGetPos(), 10.0, []);
         llWanderWithin(llGetPos(), <10.0, 10.0, 5.0>, [WANDER_PAUSE_AT_WAYPOINTS, TRUE]);
     }
     }
}
}
</lsl> |
</source>  
also_functions=
|also_functions=
* [[llCreateCharacter]]
* [[llCreateCharacter]]
* [[llDeleteCharacter]]
* [[llDeleteCharacter]]
Line 45: Line 41:
* [[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 02:41, 28 January 2024

Summary

Function: llWanderWithin( vector origin, vector dist, list options );

Sets a character to wander about a central spot within a specified radius.

• vector origin Central point to wander about
• vector dist Sets how far the character may wander from origin, along each world-aligned axis
• list options WANDER_* flags and their parameters

Option V Parameters Default Description
WANDER_PAUSE_AT_WAYPOINTS ] 0 integer boolean ] FALSE ] Whether the character should pause after reaching each wander waypoint.

Caveats

  • Must use llCreateCharacter or script won't compile.
  • Wander area is a rough area based on the specified origin, to a specified scale on each axis. So, if <20, 10, 2> is specified the object will wander within 20m along the world x-axis, 10m along the world y-axis, and 2m along the world z-axis.
    • if dist has any dimension less than 1.0, an error is shouted on DEBUG_CHANNEL. Scale too small. All dimensions must be at least 1.0.
  • When WANDER_PAUSE_AT_WAYPOINTS is enabled, PU_GOAL_REACHED and PU_SLOWDOWN_DISTANCE_REACHED path_update events will be trigged when approaching each waypoint. When this flag is disabled, the aforementioned path_update events will not be triggered when arriving at waypoints.
  • Wander area can be limited to a smaller area by introducing obstacles such as walls.
  • Vertical positions specified for any vectors should be chosen to be as close as possible to the actual height of the terrain requested. Large difference between the provided vertical position and the actual terrain/object will result in failure of the behavior.
  • As for all pathfinding behaviors, DO NOT rely on the detailed implementation here. The wander distance is just a rough estimate. We may change the exact shape on a whim. For fun. Or because it seems better that way. Or to ensure that you aren't relying on the detailed implementation. Don't make this another PATHBUG-69. :)
All Issues ~ Search JIRA for related Bugs

Examples

default
{
    state_entry()
    {
        llCreateCharacter([CHARACTER_MAX_SPEED, 25, CHARACTER_DESIRED_SPEED, 15.0]);
        //MAX_SPEED is @ 20 by default
    }

    touch_start(integer total_number)
    {
        llWanderWithin(llGetPos(), <10.0, 10.0, 5.0>, [WANDER_PAUSE_AT_WAYPOINTS, TRUE]);
    }
}

Deep Notes

History

Date of Release 31/07/2012

Search JIRA for related Issues

Signature

function void llWanderWithin( vector origin, vector dist, list options );