iCade Posted May 17, 2013 Share Posted May 17, 2013 Hello there, I've been attempting to make a swing, however I cannot for the life of me wrap my head around the rotations.Right now, the swing swings from left to right, instead of back to forth. I've been at this for an hour and still am no further. I am sure I am missing something fundamental, could anyone point me in the right direction? o.o integer swing=FALSE; float time=0.4; integer steps=12; integer swingDegrees = 10; integer i=1; float swingRad; vector normal; rotation Inverse(rotation r) { r.x = -r.x; r.y = -r.y; r.z = -r.z; return r; } rotation GetParentRot() { return Inverse(llGetLocalRot())*llGetRot(); } SetLocalRot(rotation y) { llSetRot(y*Inverse(GetParentRot())); } default { state_entry() { normal = llRot2Euler(llGetRot()); swingRad=DEG_TO_RAD*swingDegrees; llSetTouchText("Swing"); } changed(integer change) { if (change & CHANGED_OWNER) { llResetScript(); } } touch_start(integer num) { if(swing) { swing=FALSE; llSetTouchText("Swing"); } else { swing=TRUE; llSetTouchText("Stop swing"); llSetTimerEvent(time); } } timer() { float stepOffset=(float)i/steps*TWO_PI; if(i>steps) i=1; if(swing==FALSE && (i==steps || i==steps/2)) { llSetTimerEvent(0.0); SetLocalRot(llEuler2Rot(<normal.x, normal.y, normal.z + swingRad*llSin(stepOffset)>)); } else { SetLocalRot(llEuler2Rot(<normal.x, normal.y, normal.z + swingRad*llSin(stepOffset)>)); i++; } } moving_end() { normal=llRot2Euler(llGetRot()); } } Link to comment Share on other sites More sharing options...
Innula Zenovka Posted May 17, 2013 Share Posted May 17, 2013 Try SetLocalRot(llEuler2Rot(<normal.x, normal.y+ swingRad*llSin(stepOffset), normal.z >)); 1 Link to comment Share on other sites More sharing options...
iCade Posted May 17, 2013 Author Share Posted May 17, 2013 Thanks! That, and adding an invisible prim as the root prim fixed all my issues. html and css was so much easier to pick apart than lsl D: 1 Link to comment Share on other sites More sharing options...
KS Moonites Posted May 25, 2013 Share Posted May 25, 2013 sigh, i met this issue as well, and still confused about how to make the object run the SWING as "↑" and "↓". Link to comment Share on other sites More sharing options...
Rolig Loon Posted May 25, 2013 Share Posted May 25, 2013 Innula's single line does that. It's just changing it from rotation in the Z-axis to rotation on Y. 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