Jump to content

Slide between two points?


Suki Hirano
 Share

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

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

Recommended Posts

Is it possible to slide an object between two coordinates smoothly without altering the speed? For example slide an object in a straight path between two points, 5 seconds to and 5 seconds back and looped repeatedly. Only script I found to be able to do this is puppeteer, but it's impossible to control the speed. I know llTargetOmega loops a rotation, can't the function for translation along a straight path.

Link to comment
Share on other sites

Here is a kind of example...

if you make a root prim like a long plank like a 2x4..and

put a 2nd prim child on top of it.(linked) ,.and put this in the root

 it will slide the child up & back along the root plank's length.

 

float fTimer = 10.0; //how long to go the entire distanceinteger iSteps = 200; //how many steps to go from start to endinteger iLinknumber = 2; //link number of the moving primvector vAxis = <0.0,1.0,0.0>; //axis to move along. <1,0,0> is x-axis, <0,1,0> is y-axis, <0,0,1> is z-axisinteger iStep = 0; //control variable, don't changeinteger k;integer toggle;default{    state_entry()    { //start timer       // llSetTimerEvent((fTimer/iSteps));    }        touch_start(integer num)    {        k = !k;        if (k)        {             llSetTimerEvent((fTimer/iSteps));             llOwnerSay("on");        }        else        {             llSetTimerEvent(0);              llOwnerSay("off");            //  llResetScript();        }    }    timer()    { //remove un-changeable axis-parameters from scale        vector vScale = llGetScale();        if (vAxis.x == 0.0) {vScale.x = 0;}        if (vAxis.y == 0.0) {vScale.y = 0;}        if (vAxis.z == 0.0) {vScale.z = 0;}        if (iStep >= iSteps)        {            toggle = -1;                               }               else if (iStep <= 0)        {            toggle = 1;               }         llSetLinkPrimitiveParamsFast(iLinknumber, [PRIM_POS_LOCAL, (-vScale / 2.0) + (vScale / iSteps)*iStep]);        iStep = iStep + toggle; //add 1 or -1 to step    }}

 

Link to comment
Share on other sites


Xiija wrote:

Here is a kind of example...

if you make a root prim like a long plank like a 2x4..and

put a 2nd prim child on top of it.(linked) ,.and put this in the root

 it will slide the child up & back along the root plank's length.

 
float fTimer = 10.0; //how long to go the entire distanceinteger iSteps = 200; //how many steps to go from start to endinteger iLinknumber = 2; //link number of the moving primvector vAxis = <0.0,1.0,0.0>; //axis to move along. <1,0,0> is x-axis, <0,1,0> is y-axis, <0,0,1> is z-axisinteger iStep = 0; //control variable, don't changeinteger k;integer toggle;default{    state_entry()    { //start timer       // llSetTimerEvent((fTimer/iSteps));    }        touch_start(integer num)    {        k = !k;        if (k)        {             llSetTimerEvent((fTimer/iSteps));             llOwnerSay("on");        }        else        {             llSetTimerEvent(0);              llOwnerSay("off");            //  llResetScript();        }    }    timer()    { //remove un-changeable axis-parameters from scale        vector vScale = llGetScale();        if (vAxis.x == 0.0) {vScale.x = 0;}        if (vAxis.y == 0.0) {vScale.y = 0;}        if (vAxis.z == 0.0) {vScale.z = 0;}        if (iStep >= iSteps)        {            toggle = -1;                               }               else if (iStep <= 0)        {            toggle = 1;               }         llSetLinkPrimitiveParamsFast(iLinknumber, [PRIM_POS_LOCAL, (-vScale / 2.0) + (vScale / iSteps)*iStep]);        iStep = iStep + toggle; //add 1 or -1 to step    }}

 

Thanks this works, however this seems to only work for 1 sliding prim, and any linked prim's height (usually z coordinate) is forced to be the same as the linked prim. I want the sliding prims (more than 1 prim) to hover above the central prim, and I can't find a way to do that as I'm not sure which variable you used controls the z coordinate of the child prims.

Link to comment
Share on other sites

That's the script that Martin just posted in the LSL Scripting Library last week.  As written, it's designed to move only link #2 in the linkset.  If you want to move a different link, you'll have to change the value of iLinknumber at the top of the script.  If you want many child prims to move, you'll have to put the llSetLinkPrimitiveParams statement and the counter right after it into a loop that resets each of the child prims.  You ought to be able to adjust the Z parameter by adding an offset to the (-vscale/2.0) term in that statement  -- something like <0.0,0.0,vscale.z + 0.5> maybe.

EDIT:  OK, not quite.  See my addition to Martin's thread in the LSL Scripting Library.

Link to comment
Share on other sites

Yeah, keyframed motion is superior in many ways if the entire object is to move. That's what I understood to be the requirement from the first post, but now I'm not quite sure. If only some prims of a linkset are supposed to move, you can't really make much use of keyframed motion. (In theory, you could KFM the whole object and simultaneously slide in the opposite direction those part(s) that are supposed to remain static, but I wouldn't expect that to be very synchronized in the viewer.)

Link to comment
Share on other sites

You are about to reply to a thread that has been inactive for 3660 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...