Iva Rhapsody Posted February 13, 2018 Share Posted February 13, 2018 (edited) 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 February 13, 2018 by Iva Rhapsody Link to comment Share on other sites More sharing options...
Rolig Loon Posted February 13, 2018 Share Posted February 13, 2018 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 + ")" ); } 1 Link to comment Share on other sites More sharing options...
Iva Rhapsody Posted February 13, 2018 Author Share Posted February 13, 2018 (edited) 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 February 13, 2018 by Iva Rhapsody Link to comment Share on other sites More sharing options...
Rolig Loon Posted February 13, 2018 Share Posted February 13, 2018 Add llStopMoveToTarget(); Link to comment Share on other sites More sharing options...
Iva Rhapsody Posted February 13, 2018 Author Share Posted February 13, 2018 I tried that, adding this did the trick tho llSetVelocity( <0,0,0>, FALSE ); thanks for putting me on the right track, you're great as always 1 Link to comment Share on other sites More sharing options...
Rolig Loon Posted February 13, 2018 Share Posted February 13, 2018 Congratulations. I'm glad you found a trick that works. 1 Link to comment Share on other sites More sharing options...
Iva Rhapsody Posted February 13, 2018 Author Share Posted February 13, 2018 thanks, being chewed on by a shark is bad enough being impaled is horrible, laughs 1 Link to comment Share on other sites More sharing options...
Recommended Posts
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