These forums are CLOSED. Please visit the new forums HERE
Spin randomly on all axis? |
|
|
Brock Laszlo
Registered User
Join date: 21 Dec 2006
Posts: 3
|
12-02-2007 07:44
I have a spin script, but it will only spin in one direction at any given time. I'm looking for somethnig that will make an object spin in random directions using all axis.
|
|
Void Singer
Int vSelf = Sing(void);
Join date: 24 Sep 2005
Posts: 6,973
|
12-02-2007 09:08
llSetRot( llEuler2Rot( <llFrand( -TWO_PI )+PI, llFrand( -TWO_PI )+PI, llFrand( -TWO_PI )+PI> ) );
or maybe llTargetOmega( llVecNorm( <llFrand( -2 )+1, llFrand( -2 )+1, llFrand( -2 )+1> ), TWO_PI, TWO_PI); _____________________
|
| . "Cat-Like Typing Detected" | . This post may contain errors in logic, spelling, and | . grammar known to the SL populace to cause confusion | | - Please Use PHP tags when posting scripts/code, Thanks. | - Can't See PHP or URL Tags Correctly? Check Out This Link... | - |
|
Brock Laszlo
Registered User
Join date: 21 Dec 2006
Posts: 3
|
12-02-2007 09:34
Thanks for the Reply Void, I don't really understand scripting, could you explain to me how this would affect the prim?
I.E. Would it do random speed transitions etc? |
|
Void Singer
Int vSelf = Sing(void);
Join date: 24 Sep 2005
Posts: 6,973
|
12-02-2007 11:20
example 1 is a 1 time rotational move in a random direction
frand gives a random number from zero to the number called, PI = half a cirlce in radians, so in this case we asked for a +/- half a circle on each axis... it'll rotate to this new random facing nearly instaneously regardless of amount of change and stay there untill called again breakdown: llSetRot = changes the current rotation to whatever we tell it to llEuller2Rot = converts the vector form of rotation to the quaternion form used by setRot llFrand( -TWO_PI ) + PI = +/-PI in radians for each axis, same as +/-180 degrees example 2 does pretty much the same thing, but on the clients screen instead of on the server, and keeps spinning in that direction at a constant rate of 1 rotation/sec untill called again, removing vecNorm, and using larger ranges for frand, will give more varied speed of movement. note this method does NOT affect the objects physics, it acts as if it is not rotating at all breakdown: llTargetOmega = spins the object on the viewers screen llVecNorm = modify the vector we give to equal 1 full rotation in it's given direction Frand( -2 ) + 1 = a random amount of rotation +/-1 for each axis TWO_PI (first instance) = how many radians to spin per sec = one spin/sec TWO_PI (second instance) = how fast to get up to speed? i think... if it's the same it should start at full speed links: https://wiki.secondlife.com/wiki/llSetRot https://wiki.secondlife.com/wiki/llEuller2Rot https://wiki.secondlife.com/wiki/llFrand https://wiki.secondlife.com/wiki/TWO_PI https://wiki.secondlife.com/wiki/PI https://wiki.secondlife.com/wiki/llTargetOmega https://wiki.secondlife.com/wiki/llVecNorm also https://wiki.secondlife.com/wiki/Vector https://wiki.secondlife.com/wiki/Rotation you can do this with physics enabled objects using llApplyRotationalImpulse, but I glossed over that because there's so many gotchas in physics enabled items under havok one that I wouldn't consider it beginner material... it gives me headaches, ymmv.... but I doubt it =) _____________________
|
| . "Cat-Like Typing Detected" | . This post may contain errors in logic, spelling, and | . grammar known to the SL populace to cause confusion | | - Please Use PHP tags when posting scripts/code, Thanks. | - Can't See PHP or URL Tags Correctly? Check Out This Link... | - |
|
Brock Laszlo
Registered User
Join date: 21 Dec 2006
Posts: 3
|
12-02-2007 19:06
Wow, thanks for all the Info Void. I'll have to sift through it all and see what i can come up with!
|