I'm trying to make an follow object script. It seems that when I activate it the script only checks once for the objects position and moves to the position that first time but then stalls if I move the main object. I can then right click the "follow" object and deselect it and it will move again just one time. I used a basic follow script to start off. Did I do something wrong? or is it SLAG? lol
// Object Follow
integer on = FALSE;
vector offset = < -6, 0, 0>;
default
{
state_entry()
{
on = FALSE;
llOwnerSay("Loading"
;llSleep(5);
llOwnerSay("Ready"
;}
touch_start(integer total_number)
{
if(!on){
on = TRUE;
llOwnerSay("Engaged"
;llSetStatus(STATUS_PHYSICS, TRUE);
llSleep(0.1);
// Look for owner within 20 metres in 360 degree arc every .01 seconds.
llSensorRepeat("OBJECT", NULL_KEY, SCRIPTED, 20.0, PI, .01);
}
else{
on = FALSE;
llOwnerSay("Disengaged"
;llSetStatus(STATUS_PHYSICS, FALSE);
llResetScript();
}
}
sensor(integer total_number)
{ // Owner detected...
// Get position and rotation
vector pos = llDetectedPos(0);
rotation rot = llDetectedRot(0);
vector worldOffset = offset;
// Offset relative to owner needs a quaternion.
vector avOffset = offset * rot;
pos += avOffset; // use the one you want, world or relative to AV.
llMoveToTarget(pos,0.4);
}
}
//EOF
Thanks in advance.
G