|
Brett Bjornson
Registered User
Join date: 8 Nov 2005
Posts: 25
|
03-16-2007 09:25
I have three prims linked together to form a pendulum. I'm building a grandfather clock. The one prim has some rotation code in it This all works fine until I try to link this set up with the rest of the clock prims - then it stops working. Actually, the prim the script is in keeps working, but the two other prims originally linked to it no longer move. Here's the code in case it's a code issue. Thanks! rotation rot; // The rotation we are using float rotBy = 5.0; // Rotate set degrees integer steps = 3; // Number of steps to take integer i; // A simple counter integer T = 1;
default { state_entry() { rotBy *= DEG_TO_RAD; // Convert rotBy to radians while (T==1) // Oddly, you can't just use TRUE here - you need a variable { // Euler form is three values, rotation for some reason is four // so need conversion. We rotate by the rotation we want, divided // by the number of steps we intend to take rot = llEuler2Rot(<rotBy, 0.0, 0.0> / steps);
for (i = 0; i < steps; ++i) { // Loop to do the 'left' steps llSetLocalRot(llGetLocalRot() * rot); // Rotate 'left'. Note you multiple here. } //llSleep(wait); // wait for a bit for (i = 0; i < steps*2; ++i) { // Loop to do the 'reverse - right' steps llSetLocalRot(llGetLocalRot() / rot); // Rotate 'right'. Note you divide here. } for (i = 0; i < steps; ++i) { // Loop to do the 'left' steps llSetLocalRot(llGetLocalRot() * rot); // Rotate 'left' } } } on_rez(integer start_param) { llResetScript(); //Make sure all animations kick in. }
}
|
|
Anti Antonelli
Deranged Toymaker
Join date: 25 Apr 2006
Posts: 1,091
|
03-16-2007 11:11
Yep, the reason it's not working like you expect is that there is no *hierarchical* linking of prims in SL; there is one single root prim, and all others are children. You'll find if you make the prim that has that script in it the root prim, your whole clock will rock back and forth rather than just the pendulum. Or if some other prim is the root (as you no doubt had it) the prim with the script acts alone and is unable to exert any influence on the other parts of the pendulum. Possible solutions: - Leave the pendulum assembly unlinked from the rest of the clock. - Add code to the other pieces of the pendulum that will cause them to also move back and forth and rotate slightly along with the main piece. This is going to involve some ugly math and inter-prim communication to keep things moving in sync, and is beyond my capabilities. I'd go with option 1 personally 
|