CODE
integer follow=TRUE; //Are you to follow?
string followTarget="poolside"; //Who you're meant to follow
integer followRange=10; //How far away you're meant to be.
default
{
state_entry()
{
llSensorRepeat(followTarget, NULL_KEY, AGENT | ACTIVE | PASSIVE, 96, PI, 0.2);
}
sensor(integer detected)
{
vector where=llDetectedPos(0);
rotation look=llDetectedRot(0);
vector here=llGetPos();
float distance=llVecDist(here, where);
if(distance > followRange)
{
vector run=where - here;
float cos=(run.x / distance);
float sin=(run.y / distance);
vector aim=<0,0, llAcos(cos)>;
if(sin < 0)
{
aim+=<0,0,PI>;
}
llSetRot(llEuler2Rot(aim));
vector target=here + <cos * 2, sin * 2, (run.z / distance * 2)>;
llSetPos(target);
}
}
no_sensor()
{
llInstantMessage(llGetOwner(), "Cannot detect follow target within range.");
}
}
This is to add a function to something else, so there are ways to turn it off etc, although not in this version.
Any help please?