Hi guys, another question for the scripting gurus out there.
So far what I've got, is a linkset of 3 objects, which when complete I hope will form a fish object. So far I've managed to get a ?fin tail? to wag using the tail wag script here on the forums. To achieve this I'm using an axle as the root prim with another linked to this to form the tail. That works fine.
Now I've come to add a body to the fish and find that this is also rotating on the axle when linked together. So what I need to know is this. Is there anyway of keeping the three objects linked yet preventing the body of the fish from rotating along with the fin tail?
So what I'm after is a stationary body with the fin wagging from side to side.
Here's the wag script I'm using in the axle for the tail.
//user variables, set manually
float MaxRot=60; //in degrees
float swingtime=1.0; //seconds for a swing from centre to MaxRot
integer swing = FALSE; //Swing state
vector RotAxis;
float RotRate;
//runtime variable
rotation gBaseRot=ZERO_ROTATION;
do_swing() {
//Swing up
llTargetOmega(RotAxis,RotRate,1);
llSleep(-0.2+swingtime);
llSetLocalRot(gBaseRot*llAxisAngle2Rot(RotAxis,MaxRot*DEG_TO_RAD));
//swing to other side
llTargetOmega(RotAxis,-1*RotRate,1);
llSleep(-0.2+(swingtime*2));
llSetLocalRot(gBaseRot*llAxisAngle2Rot(RotAxis,-1*MaxRot*DEG_TO_RAD));
//And back to centre
llTargetOmega(RotAxis,RotRate,1);
llSleep(-0.2+swingtime);
llSetLocalRot(gBaseRot);
}
default {
state_entry() {
}
touch_start(integer count) {
state wag;
}
}
state wag {
state_entry() {
gBaseRot=llGetLocalRot();
RotAxis=llRot2Fwd(llGetLocalRot()); // maybe.
RotRate=(MaxRot*DEG_TO_RAD)/swingtime;
swing = TRUE;
llSetTimerEvent((swingtime * 4) - 0.6);
do_swing();
}
timer() {
if(swing == TRUE) {
do_swing();
}
else {
//stop rotation
llSetTimerEvent(0.0);
llTargetOmega(RotAxis,0,0);
llSetRot(gBaseRot);
state default;
}
}
touch_start(integer count) {
swing = FALSE;
}
}
