I have one that I made, which I use a lot. The way I do it is to just have the script constantly flipping between two states. Each time it enters a state it randomly generates a new rotation vector. The script is written differently, depending on whether you just want to randomly vary the rotation rate, or whether you want the object to actually change its rotation direction, too. Also you could vary timing by putting in a random llSleep command in each state, to avoid using timers.
Here's an example:
<CODE>
//------ Change the MaxSpeed variable to whatever you want the maximum possible rotation speed to be
float MaxSpeed = 3.0;
default
{
state_entry()
{
float randx_pos = llFrand(MaxSpeed);
float randx_neg = -llFrand(MaxSpeed);
float randy_pos = llFrand(MaxSpeed);
float randy_neg = -llFrand(MaxSpeed);
float randz_pos = llFrand(MaxSpeed);
float randz_neg = -llFrand(MaxSpeed);
float randx = (randx_pos + randx_neg);
float randx = (randy_pos + randy_neg);
float randx = (randz_pos + randz_neg);
llTargetOmega(<randx,randy,randz>,0.3,PI);
// You could also throw in a randomizing value for where you now have 0.3 in the llTargetOmega function....
llSleep(llFrand(3.0)); // ... which causes the rotation to stay the same for up to 3.0 seconds, randomly each time
state Second;
}
}
state Second
{
state_entry()
{
float randx_pos = llFrand(MaxSpeed);
float randx_neg = -llFrand(MaxSpeed);
float randy_pos = llFrand(MaxSpeed);
float randy_neg = -llFrand(MaxSpeed);
float randz_pos = llFrand(MaxSpeed);
float randz_neg = -llFrand(MaxSpeed);
float randx = (randx_pos + randx_neg);
float randx = (randy_pos + randy_neg);
float randx = (randz_pos + randz_neg);
llTargetOmega(<randx,randy,randz>,0.3,PI);
// You could also throw in a randomizing value for where you now have 0.3 in the llTargetOmega function....
llSleep(llFrand(3.0)); // ... which causes the rotation to stay the same for up to 3.0 seconds, randomly each time
state default;
}
}
</CODE>
This script results in your object randomly whizzing around, then suddenly shifting gears and going slow, or suddenly rotating back in the opposite direction, and all the while not doing it in predictable intervals. If you want it more predictable just take out the random factors in the llSleep lines, and if you want it to just rotate in one direction just remove all the calculations of positive and negative xyz values. Then it becomes very simple:
<CODE>
default
{
state_entry()
{
llTargetOmega(<llFrand(3.0),llFrand(3.0),llFrand(3.0)>,0.3,PI);
llSleep(3.0); // Or whatever delay you want...
state Second;
}
}
state Second
{
state_entry()
{
llTargetOmega(<llFrand(3.0),llFrand(3.0),llFrand(3.0)>,0.3,PI);
llSleep(3.0);
state default;
}
}
</CODE>
Of course there are probably more pretty ways to do it, but this is from someone who taught themselves scripting with lots of hair being pulled out in the process...
