LlMoveToTarget
Looking for the current API? Open the llMoveToTarget reference →
Wiki description
Critically damp to
target in tau seconds (if the script is physical)Function notes
To change the rotation in the same manner use llLookAt or llRotLookAt.
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. That is, if you try moving to llGetPos() + <10, 10, -10>, you can end up at .z-10 several meters before getting to .x-10 and .y-10. There is a demo object in the JIRA which shows this effect.
- A llMoveToTarget call 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 to llMoveToTarget - just do the llMoveToTarget before setting the object to physical.
llVecDist(llGetPos(),must be less than 65, or no movement will occur.target)- Calling llMoveToTarget with a
tauof 0.0 or less will silently fail, and do nothing. The smallest functionaltauis 0.044444444 (two physics frames, 2/45).
Examples
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);
}
}See also: functions
Shared wiki helpers
The original page also injects shared parameter notes, caveats or issue information through these helpers. Their conditional MediaWiki logic is not reproduced here; inspect the preserved helper source for additional material.
Original shared helper source (conditional wiki logic is not evaluated)
{{Issues|SVC-2441|Slowish [[llMoveToTarget]] path inconsistent when moving to a target at a -z position vs moving to +z|type=bug}}Template:LSL Function/physical
Original shared helper source (conditional wiki logic is not evaluated)
{{LSL Injection Test}}{{#if:
{{#vardefine:caveats|{{#var:caveats}}
*Only works in {{#if:{{{avatar|}}}|attachments and}} [[STATUS_PHYSICS|physics-enabled]] objects.}}
}}<noinclude>
{| {{Prettytable}}
|- {{Hl2}}
! #var
! value
|-
{{VarPair|caveats}}
|}
</noinclude>Original shared helper source (conditional wiki logic is not evaluated)
{{LSL Injection Test}}{{#if:
{{#vardefine:header_footnote|{{#var:header_footnote}}}}
{{#vardefine:p_{{{1|}}}_desc|seconds to critically damp in}}
{{#if:{{{1|}}}|{{#vardefine:hidden-text|{{#var:hidden-text}}{{LSLC|Damping}}}}}}
}}<includeonly>{{#if:{{{1|}}}|{{LSLC|Damping}}}}</includeonly><noinclude>
{| {{Prettytable}}
|-{{Hl2}}
! #var
! value
|-
{{VarPair|p_{{{1|}}}_desc}}
|-
{{VarPair|p_{{{1|}}}_hover}}
|-
{{VarPair|header_footnote}}
|}
</noinclude>Template:LSL Function/position
Original shared helper source (conditional wiki logic is not evaluated)
{{LSL Injection Test}}<noinclude>
This template is to be used to specify setup the description for position like parameters (offsets, positions, points, etc.).
Right now it's pretty basic and easy to edit. I'm wondering if these functions should be in a position parameter specific category.
====TODO====
* add clamping flag and verbiage for out of region/range coordinates.
</noinclude>{{#if:
{{#if:{{{region|}}}|
{{#if:{{{local|}}}|
{{#vardefine:p_{{{1|}}}_desc|position in {{HoverLink|Viewer coordinate frames#Region|Origin is the origin of the region which {{String|owns}} the object.|region}} or [[Viewer coordinate frames#Local|local coordinates]] depending upon the situation{{{desc|}}}}}
{{#vardefine:p_{{{1|}}}_hover|position in region or local coordinates depending upon the situation{{#if:{{{hover|}}}|{{{hover|}}}|{{{desc|}}}}}}}
|
{{#ifeq:{{{1|}}}|point|
{{#vardefine:p_{{{1|}}}_desc|A point in {{HoverLink|Viewer coordinate frames#Region|Origin is the origin of the region which {{String|owns}} the object.|region-local}} space{{#ifeq:{{{region|}}}|noZ| (z component is ignored)}}{{{desc|}}}}}
{{#vardefine:p_{{{1|}}}_hover|A point in region-local space{{#ifeq:{{{region|}}}|noZ| (z component is ignored)}}{{#if:{{{hover|}}}|{{{hover|}}}|{{{desc|}}}}}}}
|
{{#vardefine:p_{{{1|}}}_desc|position in {{HoverLink|Viewer coordinate frames#Region|Origin is the origin of the region which {{String|owns}} the object.|region coordinates}}{{#ifeq:{{{region|}}}|noZ| (z component is ignored)}}{{{desc|}}}}}
{{#vardefine:p_{{{1|}}}_hover|position in region coordinates{{#ifeq:{{{region|}}}|noZ| (z component is ignored)}}{{#if:{{{hover|}}}|{{{hover|}}}|{{{desc|}}}}}}}
}}
}}
|
{{#if:{{{local|}}}|
{{#ifeq:{{{1|}}}|offset|
{{LSL Function/offset|{{{1|}}}|local={{{local}}}}}
|
{{#vardefine:p_{{{1|}}}_desc|position in [[Viewer coordinate frames#Local|local coordinates]]{{{desc|}}}}}
{{#vardefine:p_{{{1|}}}_hover|position in local coordinates{{#if:{{{hover|}}}|{{{hover|}}}|{{{desc|}}}}}}}
}}
}}
}}
}}Original wiki source
Some wiki templates and tables need their original context. View this article on the Second Life Wiki. Technical wording and examples are retained from the source; historical guidance may differ from current behavior.