ToriBlack77 Posted March 21, 2015 Share Posted March 21, 2015 //elevator scriptfloat height = 7.5; //height of floorsinteger df; //destination floorinteger cf; //current floorfloat speed = 3; //3 second per floorllSetKeyframedMotion( [<0.0, 0.0, height*(df-cf)>, speed*(llAbs(df-cf))], [KFM_DATA, KFM_TRANSLATION, KFM_MODE, KFM_FORWARD]); Here i have simple code for my elevator at home. I need explanation about, how KeyframedMotion works.(why it not precise).As example to better understand what i mean. Lets say destination floor is 5. and current floor is 1. Global Z on 1st floor = 25.33.If we use code from abovefloat height = 7.5; //height of floors integer df = 5; //destination floor integer cf = 1; //current floor float speed = 3; //3 second per floor llSetKeyframedMotion( [<0.0, 0.0, height*(df-cf)>, speed*(llAbs(df-cf))], [KFM_DATA, KFM_TRANSLATION, KFM_MODE, KFM_FORWARD]); As result, we must go up 4 floors(5-1) for 12sec(3*4). And Global Z axis coodrinate of elevator will be 55.33(25.33 + 7.5*4). It is how supposed to be. But somehow, Global Z axis always different. Mostly its lower, about 55.30 or 55.29747 like so... BUT THATS OK... not huge problem, i just put in the end llSetRegionPos with right Z coordinate. it works perfectly.--------------------------- HERE STARTS THE MAIN QUESTION :)BUT now i added STOP button in elevator(like... realistic, hehehe)... Push button, and it says(linked message) to script in root prim call this function:if(status == "moving") //if elevator moving, then we can call pause, if it not move, nothing to pause { llSetKeyframedMotion([],[KFM_COMMAND, KFM_CMD_PAUSE]); pause = TRUE; } else if(pause) { llSetKeyframedMotion([],[KFM_COMMAND, KFM_CMD_PLAY]); pause = FALSE; }Code works as supposed to be. But now, if i click stop button(pause), and then click again(to keep moving)... Precision of Z axis coord are TOTALLY fail...if we move up from 1st floor to 5th floor. we must have Z = 55.33... but instead of it, i get 54.5... 55.1... etc... sometimes even more... What am im doing wrong? :) Please somebody, explain me :) And preferably - how to fix it? :) Link to comment Share on other sites More sharing options...
Rolig Loon Posted March 21, 2015 Share Posted March 21, 2015 Keyframed motion is an animation, controlled by your viewer, not by the SL servers. It's like llTargetOmega. When you set an object in motion with llSetKeyframedMotion, the servers do not change its position until the motion is finished. If you stop the animation at some point, the servers can't guess exactly how far the object may have moved in your own viewer, so the final position is imprecise. You might try an approach like Toy Wylie's Smooth Rotating Door script in the wiki's script library, which combines the apparent motion of llTargetOmega with real physical motion. I can't guarantee that it would work, but it would be fun to try. Link to comment Share on other sites More sharing options...
Dora Gustafson Posted March 21, 2015 Share Posted March 21, 2015 I never new until you told me the KeyFramed Motion is viewer side. A keyframed motion often has many frames and each frame's position and rotation is certainly assumed by the server The motion between frames is probably interpolated in the viewer to create a smooth looking motion The motioned object may hit and affect physical objects on its way and this can only happen server side :smileysurprised::smileyvery-happy: Link to comment Share on other sites More sharing options...
ToriBlack77 Posted March 21, 2015 Author Share Posted March 21, 2015 Agree, i think same, exactly. I always thought that KeyframedMotion is server side, and its really strange why server cant be precise and move exactly to coordinate... Well i found way to bypass problem in my script, need to test it more but so far so good. 1st way is to use STOP instead PAUSE... and then when instead of PLAY calculate new Z coord and speed. but i didnt do this way. im too lazy i still use llSetRegionPos BTW!!! Is there any way how i can prevent people to stop elevator by RightClick on it? i saw method for physical objects, but not sure if there is method for KeyframedMotion. Any suggestions? Link to comment Share on other sites More sharing options...
Qie Niangao Posted March 21, 2015 Share Posted March 21, 2015 ToriBlack77 wrote: BTW!!! Is there any way how i can prevent people to stop elevator by RightClick on it? i saw method for physical objects, but not sure if there is method for KeyframedMotion. Any suggestions? Try STATUS_BLOCK_GRAB_OBJECT -- but don't try to test it yourself, nor with any other agent that has permission to edit your objects. FWIW, I've found KFM to behave as a complicated mixture of server- and viewer-side motion. Watching object updates, even simple KFM sure seems to generate a lot more update traffic than one would see with a purely viewer-side effect such as llTargetOmega. (Also, anecdotally, I've seen pure KFM_ROTATION occasionally cause spurious translation for some rotations and not others, not dependent on normalization, but I've never tracked down what's happening with enough specificity to file a jira about it.) Link to comment Share on other sites More sharing options...
Recommended Posts
Please take a moment to consider if this thread is worth bumping.
Please sign in to comment
You will be able to leave a comment after signing in
Sign In Now