llMoveToTarget
void llMoveToTarget(vector Target, float Tau)Critically damp to Target in Tau seconds (if the script is physical).
Critically damp to position target in tau-seconds if the script is physical. Good tau-values are greater than 0.2. A tau of 0.0 stops the critical damping.
Parameters
-
Target(vector) -
Tau(float)
Drop this script in a prim to have it follow the prim owner.
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.4); // Look for owner within 20 meters 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 meter in X and up one meter in Z based on world coordinates. vector offset =<-1,0,1>;// offset = offset*llDetectedRot(0); //Adding this line will orient the follower relative to the owner's position. pos+=offset; llMoveToTarget(pos,0.4); }}Caveats
Section titled “Caveats”- When slowly moving to a lower Z value, beware of SVC-2441: the sim will incorrectly move the object down faster than it should. For example, if you try moving to
llGetPos() + <10, 10, -10>, you can end up at.z-10several meters before getting to.x-10and.y-10. - A
llMoveToTargetcall seems to persist even if physics is turned off. This is a useful trick on sluggish sims where the object can drop a bit between the call to enable physics and the call tollMoveToTarget- just do thellMoveToTargetbefore setting the object to physical. llVecDist(llGetPos(), target)must be less than 65, or no movement will occur.- Calling
llMoveToTargetwith atauof 0.0 or less will silently fail and do nothing. The smallest functionaltauis 0.044444444 (two physics frames, 2/45).
- The function uses critical damping to move the object to the target position over
tauseconds (only if the script is physical). - Good tau values are greater than 0.2.
- To stop the object from maintaining the target position, use
llStopMoveToTarget. - To change the rotation in the same manner, use
llLookAtorllRotLookAt.