erratic rotation

Creating scripts
Post Reply
User avatar
Constance Peregrine
Posts: 2349
Joined: Sun Dec 23, 2012 11:35 am
Has thanked: 2778 times
Been thanked: 1482 times

erratic rotation

Post by Constance Peregrine »

just tested this works in Kitely. i found it in a squirrel that makes it move erratically which is kinda interesting...it just seemed others may find some use for this behavior...

Code: Select all

rotation temp;
integer delay = 12;
integer count = 0;
integer switch = TRUE;
float rnd = 2;
float z;

setLocalRot(rotation rot)
{
    rotation localRot = llGetLocalRot();
    rotation parentRot = llGetRot();
    
    localRot.s = -localRot.s;
    parentRot = localRot * parentRot; //Order of ops important here.

    parentRot.s = -parentRot.s;

    llSetRot(rot * parentRot);
}


default
{
    state_entry()
    {
        llSetRot(llEuler2Rot(<0,0,180>*DEG_TO_RAD));
        z = 180;
        //setLocalRot(llEuler2Rot(<0,0,0>*DEG_TO_RAD));
        llSetTimerEvent(0.0);
        llStopSound();
        llSetTimerEvent(0.2);
    }

    timer()
    {
       
        
        if(switch) {
            rnd += -rnd;
            switch = FALSE;
        } else {
            rnd = (llFrand(2) - 1);
            switch = TRUE;
        }
        
        float x = rnd;
        float y = rnd;
        
        z += (llFrand(20) - 20);
        
        if(z > 360) { z -= 360;}
        else if(z < 0) { z += 360;}
        
        setLocalRot(llEuler2Rot(<x,y,z>*DEG_TO_RAD));
       // float t = llFrand(5.0) + 3;
       // llSetTimerEvent(t);
    }
    
    on_rez(integer start_param)
    {
        llResetScript();
    } 
}
These users thanked the author Constance Peregrine for the post (total 2):
Sarge MisfitGraham Mills
Laissez faire et laissez passer, le monde va de lui même!
My little sounds store https://www.kitely.com/market?store=2040306

Ephemeral wanderer...
User avatar
Boo Rojyo
Posts: 29
Joined: Wed Sep 04, 2013 7:47 pm
Has thanked: 60 times
Been thanked: 38 times

Re: erratic rotation

Post by Boo Rojyo »

Thanks Min, just tried it. It's got that useful look but just haven't thought of a use yet, something oddly mechanical maybe:)
These users thanked the author Boo Rojyo for the post:
Constance Peregrine
User avatar
Constance Peregrine
Posts: 2349
Joined: Sun Dec 23, 2012 11:35 am
Has thanked: 2778 times
Been thanked: 1482 times

Re: erratic rotation

Post by Constance Peregrine »

Boo Rojyo wrote:Thanks Min, just tried it. It's got that useful look but just haven't thought of a use yet, something oddly mechanical maybe:)
yea...lol
Laissez faire et laissez passer, le monde va de lui même!
My little sounds store https://www.kitely.com/market?store=2040306

Ephemeral wanderer...
User avatar
Sarge Misfit
Posts: 254
Joined: Thu Mar 14, 2013 4:10 pm
Has thanked: 5 times
Been thanked: 223 times

Re: erratic rotation

Post by Sarge Misfit »

I think I'll give it a try. I'm already thinking about adding a switch to randomly change direction. Maybe add something that would shift the position of the root prim to add more "natural" randomness to the movement. Think of fish that change direction and placement in a fish tank, or birds in the sky.
These users thanked the author Sarge Misfit for the post:
Constance Peregrine
Living life on the wrong side of a one-track mind.

National Security Threat Level: Gnat

My site: Excelsior Station
My Kitely World: Misfit's Folly
Post Reply