petitelouison Posted February 5, 2023 Share Posted February 5, 2023 Hello, I have a root for which I make a translation and a linked prim for which I make a rotation. I created this script for my tests: // Parameters to change float TIME = 3; // Time in seconds float HEIGHT = 2; // Height in meters float ANGLE = .5; // Angle in radian // Don't touch it! float TIME_BASE = .04; float f_step; vector v_pos; vector v_rot; float step; integer stop = TRUE; integer up; float fCos(float x, float y, float t) { float F = (1.0 - llCos(t * PI)) / 2.0; return x * (1.0 - F) + y * F; } move() { v_pos = llGetPos(); v_rot = llRot2Euler(llList2Rot(llGetLinkPrimitiveParams(2, [PRIM_ROT_LOCAL]), 0)); step = .0; up = TRUE; llSetTimerEvent(TIME_BASE); } default { state_entry() { f_step = 1.0 / (TIME / TIME_BASE); } on_rez(integer start_param) { stop = TRUE; llSetTimerEvent(.0); } touch_end(integer total_number) { if(stop = !stop) { llSetTimerEvent(.0); llSetLinkPrimitiveParamsFast(LINK_THIS, [PRIM_POSITION, v_pos, PRIM_LINK_TARGET, 2, PRIM_ROT_LOCAL, llEuler2Rot(v_rot)]); } else move(); } timer() { if(up) { if((step += f_step) >= 1.0) up = FALSE; } else { if((step -= f_step) <= .0) up = TRUE; } llSetLinkPrimitiveParamsFast(LINK_THIS, [PRIM_POSITION, v_pos + <0, 0, fCos(0, HEIGHT, step)>, PRIM_LINK_TARGET, 2, PRIM_ROT_LOCAL, llEuler2Rot(v_rot + <0, 0, fCos(0, ANGLE, step)>)]); } } So just 2 linked prims. It starts and stop with a click. The move is ok, the rotation is ok but... the relative position of the linked related to the root changes with shaking with a very unsightly effect. As I do both movements in the same function, I thought I wouldn't have this kind of problem. If someone has an idea to help me to get a good visual effect ! Thanks. Link to comment Share on other sites More sharing options...
Quistess Alpha Posted February 5, 2023 Share Posted February 5, 2023 26 minutes ago, petitelouison said: the relative position of the linked related to the root changes with shaking with a very unsightly effect I'm not seeing that when I just put the script in 2 linked cubes. Perhaps you could share a video of how it looks to you? Link to comment Share on other sites More sharing options...
Rolig Loon Posted February 5, 2023 Share Posted February 5, 2023 It looks nice and smooth to me inworld, but when I make a Gyazo GIF it looks like this. Link to comment Share on other sites More sharing options...
Quistess Alpha Posted February 5, 2023 Share Posted February 5, 2023 Just for my own fun, I wrote a slightly different script that does the same thing. The only difference that should actually matter is that I synced to llGetTime() rather than an incremented global step variable: float time = 6.0; float height = 2.0; float angle = .5; integer isRunning = FALSE; vector gPosA; vector gPosB; rotation gRotA; rotation gRotB; vector cosInterp(float time, float rate, vector posA, vector posB) { float ct = 0.5*(1+llCos(time*TWO_PI/rate)); return ct*posA + (1-ct)*posB; } rotation cosRotInterp(float time, float rate, rotation rA, rotation rB) { float ct = 0.5*(1+llCos(time*TWO_PI/rate)); return <ct*rA.x + (1-ct)*rB.x, ct*rA.y + (1-ct)*rB.y, ct*rA.z + (1-ct)*rB.z, ct*rA.s + (1-ct)*rB.s>; } default { state_entry() { gPosA = llGetPos(); gPosB = gPosA + <0,0,height>; gRotA = ZERO_ROTATION; gRotB = llAxisAngle2Rot(<0,0,1>, angle); //llSetTimerEvent(0.044); } touch_end(integer n) { llResetTime(); llSetLinkPrimitiveParamsFast(LINK_THIS, [ PRIM_POSITION,gPosA, PRIM_LINK_TARGET, 2, PRIM_ROT_LOCAL, gRotA ]); llSetTimerEvent(0.044*(isRunning=!isRunning)); } timer() { float t = llGetTime(); vector pos = cosInterp(t,time,gPosA, gPosB); rotation rot = cosRotInterp(t,time,gRotA, gRotB); llSetLinkPrimitiveParamsFast(LINK_THIS, [ PRIM_POSITION,pos, PRIM_LINK_TARGET, 2, PRIM_ROT_LOCAL, rot ]); } } Link to comment Share on other sites More sharing options...
petitelouison Posted February 5, 2023 Author Share Posted February 5, 2023 (edited) Hello, Thanks for the fast answer ! I don't know why, but now it works smooth for me in world. Maybe this was laggy when I made my test before. Sync on llGetTime() is interesting, I never thought to use it this way. I can't notice a visual difference but it's nice to see how someone else would make the same thing. Edit : today I get the same shaking issue. I made a video but I really don't know how to put it here. Edited February 6, 2023 by petitelouison 1 Link to comment Share on other sites More sharing options...
petitelouison Posted February 16, 2023 Author Share Posted February 16, 2023 I come back to my question because for me, it is still not solved. I have only seen once a correct functioning without jerks. Now I always get these unsightly jerks that I don't know how to solve. I don't know how to put a video here to show what I get. Link to comment Share on other sites More sharing options...
Quistess Alpha Posted February 16, 2023 Share Posted February 16, 2023 56 minutes ago, petitelouison said: Now I always get these unsightly jerks that I don't know how to solve. did you try llKeyframeMotion? it's a bit harder to get a handle on for things like this though. Link to comment Share on other sites More sharing options...
petitelouison Posted February 16, 2023 Author Share Posted February 16, 2023 Thanks for answer. I used llKeyframeMotion for lift but never for this kind of thing, I'll have a look. 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