I am, for my own amusement, creating something that rezzes a ghost when people visit part of my sim, and the ghost then follows them about for a minute.
Everything is working reasonably as I want it to, except that the ghost, when rezzed, is remarkably fickle. That is, if the avi it's haunting comes too close to another avi, it is very likely to start following the second avi. How, please, do I change the code so it sticks to the first avi it finds?
default {
on_rez(integer start_param) {
llResetScript();
llSensor("", NULL_KEY, AGENT, 10, PI);
}
state_entry()
{
vector pos = llGetPos();
llSetStatus(STATUS_ROTATE_X | STATUS_ROTATE_Y, FALSE);
llSetStatus(STATUS_PHYSICS, TRUE);
llSleep(0.1);
llMoveToTarget(pos,0.1);
llSetTimerEvent(60.0);
llSensorRepeat("",NULL_KEY,AGENT,10, PI,1);
}
sensor(integer detected)
{
vector pos = llDetectedPos(0);
vector offset =<-1,0,0>;
pos+=offset;
llMoveToTarget(pos,.3);
}
timer() {
llDie();
}
}