Don't click here unless you want to be banned.

LSL Wiki : llMoveToTarget

HomePage :: PageIndex :: RecentChanges :: RecentlyCommented :: UserSettings :: You are crawl814.us.archive.org
llMoveToTarget(vector target, float tau)

Critically damps a physical object's location to position target over tau seconds. Calling llStopMoveToTarget stops the damping. The target is specified in region coordinates. This function returns immediately.

To know when the object actually reaches its target see the at_target and not_at_target events and the llTarget function.

If the target is too far away from the object's current position (~60 meters), or if tau is too small (0.2 is a good tau), this will silently damp it to the object's current position. The interesting thing is the object is in fact damping to its current position when outside the range as opposed to failing completely, but if you move it back to within 60m it will snap back to the target position.

NOTE:I have tried using llMoveToTarget to move my personal av with the object attached to me, and, there at least, it seems it works until 64.999. It will not do 65, but 64.999999999999....etc will work. I used an integer to save it from the message, don't know if that's got anything to do with it.
Argus Stravinsky

Example: The example below will help prevent the 60 meter cap on the function llMoveToTarget.
MoveTarget(vector Pos) //Userfunc
{
    do //Do-while loop.
    {
        llPushObject((Key of agent/physical object moving),(Pos-llGetPos())*(llVecDist(llGetPos(),Pos)),ZERO_VECTOR,FALSE); //Pushes the avatar to the position.
        llMoveToTarget(Pos,0.05); //If your agent gets close to the avatar it will direct the path.
    }
    while(llVecDist(Pos,llGetPos()) > 40.0); //End of do-while loop.
    llMoveToTarget(Pos,0.05); //Movement
    llSleep(0.25); //Prevents you from flying.
    llStopMoveToTarget(); //Stops the movement
}

Kageshen Kirax

Note: The force created by calling this function persists until llMoveToTarget is called again with another target in the same script, is called with a tau of 0.0, or llStopMoveToTarget is called. This can be either helpful or hindersome, especially when using a combination of llApplyImpulse and llMoveToTarget.

Warning: If a llMoveToTarget is called from a script while a llMoveToTarget has been previously called from another script and is still running, the second one will silently fail.

This function uses energy at a rate controlled by the tau parameter (even if the object is at the target position). This occurs in parallel with script execution. At around 800+ kilograms mass an object will be too heavy for llMoveToTarget to resist gravity. At that point, gravity will overcome the rate at which energy is replenished and the object will most likely fall to the ground.

Use llSetPos for non-physical objects. llRotLookAt can be used to rotate physical objects.

Example: see at_target

Q: Is there a way of moving an object physically like llMoveToTarget on local axis?
A: try llMoveToTarget(llGetPos() + localaxisoffset * llGetRot(), damp) - Merlin Alphabeta

Q: Does this function work in a child prim of a link set?
A: No. Either put the script in the root prim or use linked messages to relay between the child prim and root prim.

Q: How do I target another avatar or multiple avaters?
A: use llSensor(....) to find the avatar and then use llDetectedPos(0) to find his/her position.

This article wasn't helpful for you? Maybe the related article at the LSL Portal is able to bring enlightenment.

Functions | Dynamics
Comments [Hide comments/form]
Hmm so is there a way to make the llMoveToTarget function act on the X and y axis but not the Z axis?
if i use a very weak force and try to grab my object to a distance of 50 meters, is it gonna move on the Z axis right at the begining?

(seeking a way to use the function without ending with a flying object)
-- KyrahAbattoir (2005-01-11 06:57:43)
Some smart vector maths might do it. You know the height of the object you want to affect (llGetPos, llDetectedPos() etc.), and you put that into the target vector along with your new X and Y positions.
-- EloisePasteur (2005-08-23 06:32:19)
Here's something that might help:
moveOnPlaneTo(vector destination, float tau) {
    vector curPos = llGetPos();
    destination.z = curPos.z;
    llMoveToTarget(destination, tau);
}

Just use moveOnPlaneTo instead of llMoveToTarget in the rest of your code.
-- ChristopherOmega (2005-08-23 11:52:18)
Did this function just change from 65m to 30m?
-- KairaOverdrive (2006-01-03 02:53:02)
As of the time of this post, llMoveToTarget seems to stop working on attached physical objects (like goto and hug attachments) whenever the script is saved while inside the attached object. Un/Reattaching the object fixes this problem.
-- DirtyMcLean (2006-04-25 19:06:43)
I would like to confirm DirtyMcLean's report, this problem made for a very annoying debugging session just now.
-- ZhanZhao (2006-10-21 20:52:21)
As of the time of this report, llMoveToTarget in a non-root prim doesn't appear to move the whole object. Grr.
-- EloisePasteur (2006-11-13 04:09:03)
Re: Dirty's comment. Saving a script in an attached object hoses ANY physical calls like llMoveToTarget, llSetForce, llApplyImpulse, ... until detaching and reattaching. :p
-- 64-128-27-131.static.twtelecom.net (2007-07-16 15:52:05)
A question for everyone. How does moving across a sim boundary affect calls on llMoveToTarget and llTarget? I'm trying to work on a project and I've hit this as the last roadblock.
-- 72-161-171-159.dyn.centurytel.net (2007-08-12 23:53:03)
Attach a comment to this page: