Difference between revisions of "LlMoveToTarget"

From Second Life Wiki
Jump to navigation Jump to search
(replace fairly useless example)
Line 11: Line 11:
|caveats
|caveats
|constants
|constants
|examples======Will Move your object to a position=====
|examples=<pre>
<pre>
// script created by SpiritWolf Chikuwa
//
// /!\ PUBLIC DOMAIN /!\
// You can Copy/Mod/Trans
// Please, do not resell this script and give it full perm
// Just please leave this header intact
//
// Minor changes: (insert your name here and delete this comment if you do any mod of this script, thank you)
//
// Script start here:
 
default
default
{
{
     state_entry() //i use for this example a "state_entry", so the item move the first second you
     state_entry()
                  //rez it, but if needed you can change it with something else like "touch_start",
                  //it's will move only if you click on it, the alternative of "stat_entry" is
                  //"on_rez", the item will move only if rezzed, and now directly when the script
                  // will be compiled
     {
     {
         llSetStatus(STATUS_PHYSICS | STATUS_PHANTOM, TRUE); // of course llSetStatus must be used
        vector pos = llGetPos();
// with physic (we move the item, and phantom, it's not needed, but better if the object must
         llSetStatus(STATUS_PHYSICS, TRUE);
// don't collide with something on his way. Also, it's physic, so be carefull, only 31 prims
        // Little pause to allow server to make potentially large linked object physical.
// for an item allowed.
        llSleep(0.1);
         llMoveToTarget(<53.654,199.364,502.542>, 10); // this is waht we want the llMoveToTarget,
        llMoveToTarget(pos,0.4);
// will move the item to the axes X,Y,Z localy on the curent sim where is the prim, in the 10
        // Look for owner within 20 metres in 360 degree arc every 1 seconds.
// on this exampel is the speed, actually, the item will move slowly
         llSensorRepeat("", llGetOwner(), AGENT, 20.0, PI,1.0);
    }
    sensor(integer total_number)
    {
        // Get position of detected owner
        vector pos = llDetectedPos(0);
        // Offset back one metre in X and up one metre in Z based on world coordinates.
        // Offset relative to owner is possible but beyond the scope of this example.
        vector offset =<-1,0,1>;
        pos+=offset;
        llMoveToTarget(pos,0.4);   
     }
     }
}
}

Revision as of 19:35, 5 July 2007

Summary

Function: llMoveToTarget( vector target, float tau );

Critically damp to target in tau seconds (if the script is physical)

• vector target region position
• float tau seconds to critically damp in

To stop the object from maintaining the target positions use llStopMoveToTarget
To change the rotation in the same manner use llLookAt or llRotLookAt.

Examples

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 metres 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 metre in X and up one metre in Z based on world coordinates.
        // Offset relative to owner is possible but beyond the scope of this example.
        vector offset =<-1,0,1>;
        pos+=offset;
        llMoveToTarget(pos,0.4);     
    }
}

Deep Notes

Search JIRA for related Issues

Signature

function void llMoveToTarget( vector target, float tau );