|
Django Yifu
Beat Island Gaffer
Join date: 7 May 2007
Posts: 189
|
05-28-2007 09:34
I have created a rotation script which causes a linked object to rotate 90 degrees one way as if winding up then release and rock back to it's starting point. After a pause the whole script resets. The behaviour is great but if I leave the object sitting around running the script for a few hours it tends to drift from it's starting position. Over a day it moves maybe a 1/2 meter.
This is an example of my rotation
rotation Y_rot = llEuler2Rot( < 0, -5 * DEG_TO_RAD, 0 > );
for( i = 1; i < 19; i++ ) { rotation newRotation = Y_rot * llGetRot(); llSetRot( newRotation ); }
Can anyone help with this problem?
|
|
Sterling Whitcroft
Registered User
Join date: 2 Jul 2006
Posts: 678
|
05-28-2007 11:34
Yes. its accumulating floating point errors. Try this. When first Rezzed, have the object query and remember its exact position on the grid. (x,y,z) coordinates. then, once an hour or once a minute, or once every 100 times through your loop, have it reposition itself to the stored location. (frequency of this depends on how often you are calling the rotation, and how far and fast its drifting.)
|
|
Django Yifu
Beat Island Gaffer
Join date: 7 May 2007
Posts: 189
|
05-29-2007 02:01
Thanks Sterling. Wish I'd thought of that earlier. Working great now. I just reset the position every iteration of the script. Works great now
|