LlFleeFrom
Looking for the current API? Open the llFleeFrom reference →
Wiki description
Directs a character to keep a specific
distance from a specific position in the region or adjacent regions.Caveats
- Must use llCreateCharacter or script won't compile.
- The
positionto flee from must be near the nav mesh; otherwise, this behavior will fail and trigger path update with PU_FAILURE_INVALID_GOAL. - If you want to avoid an agent or object as per the example below, it's much more elegant and less sim resource intensive to use llEvade 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 = llDetectedPos(0);
llFleeFrom(last_touched_pos, 10, []);
llSetTimerEvent(0.2);
}
timer()
{
vector last_touched_pos_now = llList2Vector(llGetObjectDetails(last_touched_key, [OBJECT_POS]), 0);
if ( llVecDist(last_touched_pos, last_touched_pos_now) > 1 )
{
last_touched_pos = last_touched_pos_now;
llFleeFrom(last_touched_pos, 10, []);
}
}
}Notes
The position vector can be set outside the current region by using extended range region coordinates: e.g., to avoid the SE corner of the region to the East of the current one, you could
llFleeFrom(<0.0, 512.0, 0.0>, 20.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.