Jump to content

Random Texture Rotation Direction & Speed Changer


Clortbags
 Share

You are about to reply to a thread that has been inactive for 2834 days.

Please take a moment to consider if this thread is worth bumping.

Recommended Posts

Hey guys I'm using:

 

default
{
    state_entry()
    {
         llSetTextureAnim(ANIM_ON | SMOOTH | ROTATE | LOOP, 6,1,1,0, TWO_PI, -PI);
       
           }

  
}

To rotate a texture anticlockwise on one face of a prim but what I'd like to do is change direction and speed of the texture rotation at random intervals, if could also have a chance of stopping rotating too this would be even better.

Have searched on google and have found ways to do this with the prim but not the texture.

Can anyone help me out please?

Thanks in advance for your time :)

Link to comment
Share on other sites

Sure. You just need to add a timer() event and use llFrand() to randomize intervals between timer events (in the llSetTimerEvent() calls), and to randomize the rotation speed in the interval between -PI and PI (for example).

If you don't know how to start with making those changes, you need to hire a scripter to help.

Also, be aware that the original script has zero sim-side lag effect (indeed, the script could be removed once it's run), but anything that changes the texture animation while running adds a bit of sim processing and some network traffic to push the updates to the viewer. This is no big deal for a one-off, but obviously the effect accumulates when there are many of these things on the sim (or in view) at the same time.

Link to comment
Share on other sites

Actually, I'd do it all in the timer() event, just kicking off that llSetTimerEvent() in the state_entry.

if you want the interval between changes to fluctuate, you'd call llSetTimerEvent() again inside the timer() event itself, with a random value as argument to the call.

The direction A or B can be part of the speed (a negative speed goes backwards), so for example
llFrand(TWO_PI) - PI
should return a range from -PI to PI.

[edited twice to correct a mental typo -- a mento?]

Link to comment
Share on other sites

Ok thanks I appreciate your help and feel like I'm getting kind of getting somewhere with this,  I've got a working random interval timer triggering a simple llsay function every 1-5 seconds a maximum of once per second like so:

 

float time = 5.0;default{state_entry(){llSetTimerEvent(1.0);  // trigger timer event max once per second} timer(){llSetTimerEvent(1.0);  llSay(0, "Hello, Avatar!");llSetTimerEvent(1.0+llFrand(time)); //do something every 1 - 5 seconds}}

 

 

If I'm following you and this script above I should be defining 'TWO_PI - PI' as an intial variable and calling it with

 

llSetTimerEvent(1.0+llFrand(TWO_PI) - PI);

 Or am I missing the point?

 

Also in my first post I was using:

 

llSetTextureAnim(ANIM_ON | SMOOTH | ROTATE | LOOP, 6,1,1,0, TWO_PI, 2*TWO_PI);

 

I'm presuming that I remove the mode LOOP from the llSetTextureAnim function or the texture will rotate infintitly regardless of the interal timer and is there any other changes I need to make to the function?

 

Am I on the right track here?

Link to comment
Share on other sites

You're definitely sneaking up on it! :)

Just to make sure we're on the same page, we're working on two distinct applications of randomness here. First, we're making the texture animation itself random in speed and direction, so that will use llFrand to affect the settings of llSetTextureAnim itself. And second, we're making those changes occur at random times, so another llFrand will be used to affect the llSetTimerEvent.

Hence, inside the timer() event, your llSetTimerEvent(1.0+llFrand(time))correctly randomizes the interval before that event's next occurrence.  (It actually will do something every 1 - 6 seconds, because the time variable is set to 5.0 for a range of 0.0 to 5.0 and you're adding 1.0 to each value in that range.)

I didn't intend the llFrand(TWO_PI) - PI range to apply to the timer, but rather to the speed of the texture animation itself, a la

llSetTextureAnim(ANIM_ON | SMOOTH | ROTATE | LOOP, 6,1,1,0, TWO_PI, llFrand(TWO_PI) - PI);

The actual value range is kinda arbitrary for animation speed, so you'll probably want to play around with it. (The reason PI is even relevant is that the ROTATE variety of texture animation expresses its speed in radians per second, so there's nothing magical about using PI in calculating a speed setting.)

Oh, and the "do something" part, where now you have the llSay(), that's where you'd want to put the llSetTextureAnim() call, because that's where you change the speed of the animation, and each time that function is called the new setting overrides the old one (even if that old one is LOOPing), so you'll get a change in animation speed.

  • Thanks 1
Link to comment
Share on other sites

Gotcha thanks so much, some real progress now!

default{state_entry(){llSetTimerEvent(1.0);  // trigger timer event max once per second} timer(){llSetTimerEvent(2.0); //trigger the timer event every 2 seconds llSetTextureAnim(ANIM_ON | SMOOTH | ROTATE | LOOP, 6,1,1,0, TWO_PI, llFrand(3*TWO_PI) - 3*PI); //change the speed and direction of the the face 6 texture rotation between 3 revs per second clockwise & 3 revs per second anticlockwise}}

 

The direction and speed selector is now working as it should but it is triggering exactly every two seconds as per the timer so I'm halfway there!

 

I presume that I need to now go back re-define a (time) variable and use another llSetTimerEvent function that calls before the llSetTextureAnim function to pick the random time right before the random direction and speed?

Link to comment
Share on other sites

You are about to reply to a thread that has been inactive for 2834 days.

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
 Share

×
×
  • Create New...