|
Gaberoonie Zanzibar
Registered User
Join date: 16 Oct 2008
Posts: 3
|
04-14-2009 18:10
I need to script an object so that when clicked, its Z rotation is set to a random one of 12 possible angles (0, 30, 60, 90 degrees etc. up to 330). How would I go about this?
Thanx!
|
|
Viktoria Dovgal
…
Join date: 29 Jul 2007
Posts: 3,593
|
04-14-2009 18:48
To get semi-random numbers, you can use llFrand.
integer angleX = (integer)llFrand (12.) * 30;
To use those numbers in a rotation, you can convert with llEuler2Rot.
llSetRot(llEuler2Rot( <angleX, angleY, angleZ> * DEG_TO_RAD));
|
|
Gaberoonie Zanzibar
Registered User
Join date: 16 Oct 2008
Posts: 3
|
04-14-2009 19:53
Thank you! Works.
|
|
Void Singer
Int vSelf = Sing(void);
Join date: 24 Sep 2005
Posts: 6,973
|
04-14-2009 21:53
when only using a variable once replace the variable with the calculation (and if you only need to multiply one element of a vector, apply the multiplation directly to it) llSetRot( llEuler2Rot( <.0, .0, (integer)llFrand ( 12. ) * 30 * DEG_TO_RAD> ) );
_____________________
| | . "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... | - 
|