ringstadjr Posted October 3, 2011 Share Posted October 3, 2011 I'm new to this. Is there any way to create a smooth movement of objects?I have tried using setPos with a for loop and llSleep in between. Unfourtunately llSleeps has a min llSleep of 0.2, I think. So I tried making a loop by swapping states and got down to a 0.1 sec delay. Is that the best possible "smoothness"?And are there differences between physical objects and non physicals? Link to comment Share on other sites More sharing options...
Void Singer Posted October 3, 2011 Share Posted October 3, 2011 if you want smooth motion that you don't want sleeps, you just want smaller steps.... unfortunately the smaller the steps, the the slow it will go overall. your only other option at this moment for smooth movements is to use physics, either pure in the form of llMoveToTarget, or simulated in the form of vehicles (which has many complex parametrs). however on the horizon we have llSetKeyframeMotion (currently being tested as llSetKeyframedAnimation, but because of the name confusion is likely to change), which will allow physics style smooth motion without being physics enabled itself Link to comment Share on other sites More sharing options...
Tara Chester Posted October 3, 2011 Share Posted October 3, 2011 Only with physical objects, which sometimes and sometimes it doesn't... I can only guess LL has it's techical reasons not to provide us with tools for simple smooth movements of all objects. Link to comment Share on other sites More sharing options...
Monica Balut Posted October 3, 2011 Share Posted October 3, 2011 Take a look at this. It will move an object from it's present location to a target in a straight line at a constant speed. The series of target points are hard coded in a list called path. It will also rotate the object so its local x axis faces its direction of motion. In this case motion is activated by /111 goto x where x is the index of a path vector. float EVENTTIME = 0.1; float SPEED = 5.0; integer lastStop; vector currPos; vector targetPos; vector pathVector; integer currTargetIndex = 0; vector incrementVect; integer nSlices; list path = [ <89.58290, 41.27910, 2010.63500>, <89.5829, 6.2823, 2010.63500>, <119.58150, 6.2823, 2010.63500>, <119.58150, 21.28410, 2010.63500>, //room 1 <119.58150, 51.28470, 2010.63500>, //room 2 <119.58150, 81.28490, 2010.63500>, //room 3 <119.58150, 106.28520, 2010.63500>, <104.59000, 106.28520, 2010.63500>, // room 6 <74.58280, 106.28520, 2010.63500>, //room 7 <44.57620, 106.28520, 2010.63500>, //room 8 <29.6, 106.30, 2010.63500>, <29.60000, 106.28520, 2000.64200>, <29.60000, 81.28430, 2000.64200>, // room 9 <29.60000, 51.27620, 2000.64200>, //room 10 <29.60000, 21.26800, 2000.64200>, //room 9 <29.60001, 0.00000, 2000.64100> // unload area ]; MoveToPos(integer pathIndex) { currPos = llGetPos(); targetPos = llList2Vector(path, pathIndex); pathVector = targetPos - currPos; float pathDistance = llVecMag(pathVector); float thisPathTime = pathDistance / SPEED; nSlices = llRound(thisPathTime / EVENTTIME); incrementVect = pathVector / nSlices; llRotLookAt(llRotBetween(<1.0,0.0,0.0>, llVecNorm(<targetPos.x,targetPos.y,currPos.z> - currPos)),1.0,1.0); llSetTimerEvent(EVENTTIME); } listen(integer channel, string name, key id, string msg) { if (msg == "gotostart") { MoveToPos(0); } else if (llGetSubString(msg,0,3) == "goto") { string strNum = llStringTrim(llDeleteSubString(msg,0,3),STRING_TRIM); if (IsInteger(strNum)) { integer index = (integer) strNum; if (index != currTargetIndex) { currTargetIndex = index; if (currTargetIndex >=0 && currTargetIndex <= lastStop) MoveToPos(currTargetIndex); else llSay(0,"Invalid position."); } else llSay(0,"Already at that position."); } } else llSay(0, "Invalid command"); } timer() { if (nSlices > 0) { currPos = llGetPos(); llSetLinkPrimitiveParamsFast(1,[PRIM_POSITION, currPos + incrementVect]); nSlices --; } else { llSetTimerEvent(0.0); } } 1 Link to comment Share on other sites More sharing options...
Kayaker Magic Posted October 3, 2011 Share Posted October 3, 2011 Ringstadjr, you said llSleep has a min of 0.2, but actually it is llSetPos that inserts a fixed delay of 0.2 seconds. Try your loop experiment again using llSetLinkPrimitiveParamsFast instead of llSetPos and see if your motion becomes smoother. Link to comment Share on other sites More sharing options...
ringstadjr Posted October 5, 2011 Author Share Posted October 5, 2011 Tried your script but got this error: "illegal character <> 65279". Don't know what that error means,Wasn't this meant as a stand alone script perhaps? Link to comment Share on other sites More sharing options...
Rolig Loon Posted October 5, 2011 Share Posted October 5, 2011 It's not a complete script. You'd have to build it into whatever you are writing. 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