Search This Blog

Saturday, August 27, 2016

Pathfinding Script


llPursue script

default
{
    state_entry()
    {
        // Set the object as Character
        llCreateCharacter([]);
    }
 
    touch_start(integer total_number)
    {
        // Distance between Avator and character set as 2m 
        llPursue(llDetectedKey(0), [PURSUIT_OFFSET, <-2.0, 0.0, 0.0>]);
    }
}
OptionValueDescriptionUsageDefault Value
PURSUIT_OFFSET1Go to a position offset from the target.
[PURSUIT_OFFSET, vector offset]
ZERO_VECTOR
REQUIRE_LINE_OF_SIGHT2Define whether the character needs a physical line-of-sight to give chase. When enabled, the character will not pick a new target position while there is a something solid between the character and the target object/agent.
[REQUIRE_LINE_OF_SIGHT, integer boolean]
FALSE
PURSUIT_FUZZ_FACTOR3Selects a random destination near the PURSUIT_OFFSET. The valid fuzz factor range is from 0 to 1, where 1 is most random. This option requires a nonzero PURSUIT_OFFSET.
[PURSUIT_FUZZ_FACTOR, float factor]
0.0
PURSUIT_INTERCEPT4Define whether the character attempts to predict the target's future location.
[PURSUIT_INTERCEPT, integer boolean]
FALSE
PURSUIT_GOAL_TOLERANCE5Defines approximately how close the character must be to the current goal to consider itself to be at the desired position. The valid range is from 0.25 to 10m.
[PURSUIT_GOAL_TOLERANCE, float tolerance]
Default is proportional to character size

llPatrolPoints

default {
    
    state_entry()
    {
    
        llCreateCharacter([]);
    }

    touch_start(integer num)
    {
        // Sense the target
        llSensor("target", "", PASSIVE, 25.0, PI);
    }
    
    sensor(integer num)
    {
        // if only one odject, don't run the script
        if(num<=1) return;
        
        integer i;
        list l;
        
        // save the postion of target
        for(i=0; i<num; i++)
        {
            l += llDetectedPos(i);
        }
        
       
        llPatrolPoints(l, []);
    }

    no_sensor()
    {

        llOwnerSay("No target in range.");
    }
}

OptionVParametersDefaultDescription
PATROL_PAUSE_AT_WAYPOINTS ]0integer boolean ]FALSE ]Whether the character should pause briefly after reaching each patrol point.

No comments:

Post a Comment