Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Help Making A Wheel Spin??

Bendan Fisher
Registered User
Join date: 10 Jan 2006
Posts: 22
02-03-2006 17:07
Hi and thank you in advance for any help....

I am looking for a script that will make a wheel spin using the right click pie menu. Once spinning, I need this wheel to slowly come to a stop after 2 or 3 seconds.

This is not a vehicle so I'm trying not to turn physics on. The scripting Wiki explains commands such as llsetforceandtorque and llapplyimpulse for kinetic force on physical items only.

Is there a way to accomplish this without turning physics on? And if so can anyone show me how? (keep in mind I'm a complete newb to scripting ;))

I finally have the object spinning correctly with the right click menu. (Thank You Eric)
Now I just need it to slow down to a stop
Zepp Zaftig
Unregistered Abuser
Join date: 20 Mar 2005
Posts: 470
02-03-2006 18:12
It's easier to make it slow down with physics on. There are several possibilities. If you're using llTargetOmega you could do something like this to make it slow down to a halt.
CODE


default
{
state_entry()
{
llSetStatus(STATUS_PHYSICS, TRUE); //Enable physics
llGroundRepel(1.3,FALSE,0.1); // Make the object hover above the ground
llSetStatus(STATUS_ROTATE_Y|STATUS_ROTATE_Z, FALSE); //Make sure it doesn't rotate it ways it shouldn't
}

touch_start(integer total_number)
{
//Loop for slowing down the rotation to a halt
integer i;
for(i=2;i>=0;i--)
{
llTargetOmega(<1,0,0>, i*0.1*PI, 1);
llSleep(1);
}
}
}



You could also use llRotLookAt
Zepp Zaftig
Unregistered Abuser
Join date: 20 Mar 2005
Posts: 470
02-03-2006 18:21
RotLookAt would be pretty similar.. Something like

CODE

default
{
state_entry()
{
llSetStatus(STATUS_PHYSICS, TRUE); //Enable physics
llGroundRepel(1.3,FALSE,0.1); // Make the object hover above the ground
llSetStatus(STATUS_ROTATE_Y|STATUS_ROTATE_Z, FALSE); //Make sure it doesn't rotate it ways it shouldn't
}

touch_start(integer total_number)
{
llRotLookAt(llGetRot() + <0,0,0,1>, 1, 3);
}
}
Bendan Fisher
Registered User
Join date: 10 Jan 2006
Posts: 22
02-03-2006 19:31
I think I can get it to work with the targetomega command. I'm still tweaking it to see how it goes. But......I need the wheel to stop at a random location, as it is now its rotating back to the original starting point before it stops. Is there a way to get it to stop at a random location around the radius of the wheel?
Introvert Petunia
over 2 billion posts
Join date: 11 Sep 2004
Posts: 2,065
02-03-2006 19:38
Apply a random rotation immedaitely prior to applying the physical impulse? I'm kind of surprised that the physics are that deterministic, but accept your evidence as true.

Incidentally, last I tested it, llFrand() was sufficiently random, with nearly low-grade encryption randomness. (I say "nearly" as I was just testing for game level random and didn't get enough data to prove higher grade).
Bendan Fisher
Registered User
Join date: 10 Jan 2006
Posts: 22
02-03-2006 19:48
How would I do it using llFRand?

Here is what I have so far....I did accomplish the proper spin without using the physics...

CODE

default
{
state_entry()
{
llSetTouchText("Spin");
}


touch_start(integer total_number)
{
llSay(0, "Spinning The Wheel.");
integer i;
for(i=25;i>=0;i--)
{
llTargetOmega(<0,1,0>, i*0.1*PI, 1);
llSleep(1);
}
}
}

Zepp Zaftig
Unregistered Abuser
Join date: 20 Mar 2005
Posts: 470
02-03-2006 20:59
Calling llTargetOmega repeatedly in that is might not be the best of going about this. If llTargetOmega is used on a nonphysical prim it doesn't save its current rotation when you call it again. Better to use llRotLookAt, it works nonphysical too. Maybe something like this will do.
CODE

touch_start(integer total_number)
{
integer i;
for(i=0; i<10; i++)
{
llRotLookAt(llEuler2Rot(<i*PI / llFrand(5),0,0>) * llGetRot(),0.3,0.3);
}
}
Bendan Fisher
Registered User
Join date: 10 Jan 2006
Posts: 22
02-03-2006 21:35
From: Zepp Zaftig
Calling llTargetOmega repeatedly in that is might not be the best of going about this. If llTargetOmega is used on a nonphysical prim it doesn't save its current rotation when you call it again. Better to use llRotLookAt, it works nonphysical too. Maybe something like this will do.
CODE

touch_start(integer total_number)
{
integer i;
for(i=0; i<10; i++)
{
llRotLookAt(llEuler2Rot(<i*PI / llFrand(5),0,0>) * llGetRot(),0.3,0.3);
}
}



This did the trick, but now its spinning on the wrong axis LOL. I need it to spin on the Z axis, right now its spinning the X axis. Is there a way to set which axis to use with llRotLookAt?
Zepp Zaftig
Unregistered Abuser
Join date: 20 Mar 2005
Posts: 470
02-03-2006 22:00
From: Bendan Fisher
This did the trick, but now its spinning on the wrong axis LOL. I need it to spin on the Z axis, right now its spinning the X axis. Is there a way to set which axis to use with llRotLookAt?


Yeah, this should spin on z
llRotLookAt(llEuler2Rot(<0,0,i*PI / llFrand(5)>;) * llGetRot(),0.3,0.3);
Bendan Fisher
Registered User
Join date: 10 Jan 2006
Posts: 22
02-03-2006 22:58
Thank You very much Zepp Zaftig and Introvert Petunia That did the trick perfectly!