Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Changing degree of rotation in Swing Script

Danni Bekkers
Registered User
Join date: 17 Feb 2007
Posts: 74
03-23-2008 04:26
I'm a total scripting noob, apart from managing to edit hover text & the odd colour changer & have a question about amending a swing script. I have it in a hammock but it is rotating too far, & it looks too unrealistic... as in people would be rolling off ;)

I'm trying to understand which part of the script to edit to reduce the swing. I think it should be ok to post the script here as it is full perms so long as credit is included.

//Created by Sandeo Goodman. Free to use as long as credit remains :-)
float distance = 1.3;
float timetotake = 2.4;
float speed;
rotation backrot;
rotation forerot;
rotation stoprot;

startSwing()
{
vector vDir;

speed = distance / timetotake;
// llOwnerSay("Speed = " + (string)speed + " at start";);
llSetTimerEvent(timetotake);
vDir = llRot2Up(llGetRot());
llSetRot(stoprot);
llTargetOmega( vDir, -distance / ( 2 * timetotake ), 1.0 );
}

swingchange()
{
vector vDir = llRot2Up(llGetRot());

// llOwnerSay("timer(): gain=" + (string)gain);
// llTargetOmega( <0,0,0>, speed, 1.0 );
if( speed < 0 ) {
llSetRot(backrot);
} else {
llSetRot(forerot);
}
llTargetOmega( vDir, speed, 1.0 );
speed = 0 - speed;
}

integer swinging = 0;

default
{
on_rez(integer sp)
{
llResetScript();
}

state_entry()
{
rotation rrot = llGetRot();
vector vrot = llRot2Euler( rrot );
stoprot = rrot;
vrot.z += distance/2;
backrot = llEuler2Rot( vrot );
vrot.z -= distance;
forerot = llEuler2Rot( vrot );

// vector vrot = llRot2Euler( llGetRot() );
// vrot.z = (distance/2);//2 * speed;
// backrot = llEuler2Rot( vrot );
// vrot.z = -(distance/2);//-2 * speed;
// forerot = llEuler2Rot( vrot );
llTargetOmega(<0,0,0>, 0, 0.0);
swinging = 0;
// vrot.z = 0;
// stoprot = llEuler2Rot( vrot );
// llSetRot( stoprot );
// llOwnerSay("Backrot: " + (string)backrot + ", forerot: " + (string)forerot);
}

timer()
{
swingchange();
}

touch_start(integer total_number)
{
if( swinging > 0 ) {
swinging = 0;
llSetTimerEvent(0.0);
llTargetOmega(<0,0,0>, 0, 0.0 );
llSetRot(stoprot);
llTargetOmega(<0,0,0>, 0, 0.0 );
} else {
swinging = 1;
startSwing();
}
}

moving_end()
{
llSleep(2.0);
llResetScript();
}
}


Can anybody please advise me?

Thank you :)
_____________________
DB Designs - Low Prim Outdoor Furniture

Now in our new island store!

http://slurl.com/secondlife/Seaview/84/107/21
Lee Ponzu
What Would Steve Do?
Join date: 28 Jun 2006
Posts: 1,770
I didn't study it carefully, but...
03-23-2008 10:50
//Created by Sandeo Goodman. Free to use as long as credit remains :-)
float distance = 1.3;
float timetotake = 2.4;
float speed;

It looks to me like you should change distance to a smaller number. And, if the swing is too fast or slow, change timetotake.
_____________________
So many monkeys, so little Shakespeare.