Difference between revisions of "Follower script"

From Second Life Wiki
Jump to: navigation, search
m (remove entirely incorrect description of llMoveToTarget parameters)
(spell out llSensorRepeat parameters and more comments)
Line 8: Line 8:
 
         vector pos = llGetPos();
 
         vector pos = llGetPos();
 
         llSetStatus(STATUS_PHYSICS, TRUE);
 
         llSetStatus(STATUS_PHYSICS, TRUE);
 +
        // Little pause to allow server to make potentially large linked object physical.
 
         llSleep(0.1);
 
         llSleep(0.1);
         llMoveToTarget(pos,0.1);
+
         llMoveToTarget(pos,0.2);
         key id = llGetOwner();
+
         // Look for owner within 20 metres in 360 degree arc every 1 seconds.
         llSensorRepeat("", id, AGENT, 96.0, PI, 0.4);
+
         llSensorRepeat("", llGetOwner(), AGENT, 20.0, PI,1.0);
 
     }
 
     }
 
     sensor(integer total_number)
 
     sensor(integer total_number)
 
     {
 
     {
 +
        // Get position of detected owner
 
         vector pos = llDetectedPos(0);
 
         vector pos = llDetectedPos(0);
 +
        // Offset back one metre in X and up one metre in Z based on world coordinates.
 +
        // Offset relative to owner is possible but beyond the scope of this example.
 
         vector offset =<-1,0,1>;
 
         vector offset =<-1,0,1>;
 
         pos+=offset;
 
         pos+=offset;
         llMoveToTarget(pos,0.0);     
+
         llMoveToTarget(pos,0.2);     
 
     }
 
     }
 
}
 
}

Revision as of 19:27, 5 July 2007

This script was extracted from the Batman Follower v1.2, but the following distance was changed from .3 m to .1 m.

default
{
    state_entry()
    {
        vector pos = llGetPos();
        llSetStatus(STATUS_PHYSICS, TRUE);
        // Little pause to allow server to make potentially large linked object physical.
        llSleep(0.1);
        llMoveToTarget(pos,0.2);
        // Look for owner within 20 metres in 360 degree arc every 1 seconds.
        llSensorRepeat("", llGetOwner(), AGENT, 20.0, PI,1.0);
    }
    sensor(integer total_number)
    {
        // Get position of detected owner
        vector pos = llDetectedPos(0);
        // Offset back one metre in X and up one metre in Z based on world coordinates.
        // Offset relative to owner is possible but beyond the scope of this example.
        vector offset =<-1,0,1>;
        pos+=offset;
        llMoveToTarget(pos,0.2);     
    }
}