llFleeFrom
void llFleeFrom(vector Source, float Distance, list Options)Flee from a point.
Directs a character (llCreateCharacter) to keep away from a defined position in the region or adjacent regions.
Parameters
-
Source(vector) - Global coordinate from which to flee.
-
Distance(float) - Distance in meters to flee from the source.
-
Options(list) - No options available at this time.
- Must use
llCreateCharacteror script won’t compile. - The position to flee from must be near the nav mesh; otherwise, this behavior will fail and trigger
path_updatewithPU_FAILURE_INVALID_GOAL(0x03). - If you want to avoid an agent or object, it’s much more elegant and less sim resource intensive to use
llEvadeinstead.
Examples
Section titled “Examples”This example tracks an agent’s position and continuously updates the flee target:
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, []); } }}The position vector can be set outside the current region by using extended range region coordinates. For example, to avoid the SE corner of the region to the east of the current one:
llFleeFrom(<0.0, 512.0, 0.0>, 20.0, []);