Jump to content

stopping an object short of it's target


Iva Rhapsody
 Share

You are about to reply to a thread that has been inactive for 2261 days.

Please take a moment to consider if this thread is worth bumping.

Recommended Posts

I tend to get turned around any time rotations come into play :)

I'm using the following code to point an objects x axis towards a target position and moving it to it via llMoveToTarget and it works just fine however I want it to actually stop .5 meters short of the actual target, can anybody point me in the right direction laughs...

Next()
{
        index++;
        if (index >= llGetListLength(targets))
        {
            index=0;
        }
        target = llList2Vector(targets,index);
        mytarget =  llTarget( target, .3 );
        float dist=llVecDist(target,llGetPos());
        integer speed2=6 - llList2Integer(speeds,index);
        llMoveToTarget( target, speed2*(dist/4));
        vector pos =  llGetPos();
        llRotLookAt( llRotBetween( <1.0,0.0,0.0>, llVecNorm( <target.x,target.y,pos.z> - pos ) ), 1.0, .2);
    }  
}

Edited by Iva Rhapsody
Link to comment
Share on other sites

mytarget = llTarget(target,0.5);

You can test that this will stop you 0.5m from the target by watching to see when the at_target and not_at_target events are triggered (example scriptlets from the LSL wiki):

at_target(integer tnum, vector targetpos, vector ourpos)
    {
        if (tnum == mytarget)
        {
            llOwnerSay("object is within range of target");
            llOwnerSay("target position: " + (string)targetpos + ", object is now at: " + (string)ourpos);
            llOwnerSay("this is " + (string)llVecDist(targetpos, ourpos) + " meters from the target");
            llTargetRemove(mytarget);
        }
    }
    not_at_target()
    {
        llOwnerSay(
            "not there yet - object is at " + (string)llGetPos() +
            ", which is " + (string)llVecDist(target_pos, llGetPos()) +
            " meters from the target (" + (string)target_pos + ")"
        );
    }
  • Like 1
Link to comment
Share on other sites

It seems that the object continues to "coast" along afterwards, when I remove the target I trigger an animation(hiding, showing certain surfaces on the objects mesh and releasing particles..this appears to occur at 2.75 meters which is the distance I decided on so that the object just touches the target object ie. offsetting centers so the edges meet, but the object in motion continues on and punches into the target...any ideas ?

Edited by Iva Rhapsody
Link to comment
Share on other sites

You are about to reply to a thread that has been inactive for 2261 days.

Please take a moment to consider if this thread is worth bumping.

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
 Share

×
×
  • Create New...