Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

rotating acts strangly

AndroGyne Qinan
Registered User
Join date: 8 Apr 2007
Posts: 8
12-10-2008 05:33
Hello,
I want to turn a object round like a wheel. The script i have dus turn around the good axis but it turns not around but turns forward, backwards etc. It is build in a timer to stop the spinning easily. Hope you guys can help me out.

<code>
timer(){
angle = angle + 44;
integer remainder = (integer)angle % 360;
if( remainder == 0.0){
//angle -= 360;
distance += 7.07143;
llMessageLinked(LINK_ROOT,1, (string)((integer)distance) ,NULL_KEY);
}

vector eul = <0,00,angle>; //45 degrees around the z-axis, in Euler form
eul *= DEG_TO_RAD; //convert to radians
rotation quat = llEuler2Rot(eul) * llGetLocalRot(); //convert to quaternion
llSetLocalRot(quat);
}
</code>
regads
Andro
Ollj Oh
Registered User
Join date: 28 Aug 2007
Posts: 522
12-10-2008 10:52
http://wiki.secondlife.com/wiki/LSL_Operators (too complicated example)
http://en.wikipedia.org/wiki/Modulo_operation (way too general for sls)

your problems are using
"if( remainder == 0.0){"
while your increment "+44" is not a whole fraction of the 360 full circle!
so that "==" condition is not true when it should.

if( remainder < 44 ){
or
if( remainder < 43 ){
should work

not sure yet.
using integers may be a dumb decision, way too inaccurate large steps.
AndroGyne Qinan
Registered User
Join date: 8 Apr 2007
Posts: 8
12-10-2008 23:08
Thanks will try different steps and cnage the if(... == remainder) statement

Thanks