Vance Adder
Registered User
Join date: 29 Jan 2009
Posts: 402
|
08-21-2009 07:08
I have some code that animates my avatar reaching for a sword, hiding the original prim, and making the one in his hand visible. I noticed that getting the animation to "sync up" with the hiding/displaying of the two prims can take a bit of tweaking. Here is more or less the order in which I do things: llStartAnimation("sword_draw_1"); // start the animation to reach for the sword llSleep(1.0); llPlaySound("sword_unsheath", 1.0); llWhisper(g_Channel,"draw_sword"); // messages the held sword to become visible llSetLinkAlpha(LINK_SET, 0.0, ALL_SIDES); // hide the sheathed sword
I understand that llSleep can be inaccurate sometimes and I don't want my animation to end up completing before the sword appears in the hand and the sound plays. Would it perhaps help to split my animation into two animations? Play one animation to reach for the sword, then delay, then play an animation to pull the sword free along with the rest of the toggling/sounds. Any suggestions? Does this seem like a pretty sensible way to do what I want? The code above works well, but my testing has been with pretty ideal conditions.
|
Yuriko Nishi
Registered User
Join date: 27 Feb 2007
Posts: 288
|
08-21-2009 08:27
linking avatar animations to prim animations is allways a problem for a few reasons. first it depends on the sim performance. in a slow sim a llSleep(1); can take 2 seconds, and also it takes a bit longer before the sim sends out the avatar animation trigger. and 2nd keep in mind that people who do not have the animation in their ram need to download it when you trigger it the first time, so that will be messed up too (same for the sound). your idea about 2 animations is not bad in theory, but i can“t tell how much it would help, i guess you will just have to try around a bit  i would aim for a timing that works good in a fast sim with 44-45 fps, since fighting is no fun in laggy sims anyway  edit: your script seems good for what you wanna do
|
Celty Westwick
Registered User
Join date: 24 Jun 2006
Posts: 145
|
08-21-2009 08:49
You could try using a timer for more precision rather than sleep, though when I've tested in laggy sims doing this the sleep still stayed within a tolerance range of synching with animation and sound, so i stuck with it. The less satisfactory part to me is if you are using a scabbard that should not alpha, and just the sword parts. I would have preferred to filter those parts with a llSetLinkAlpha and a for statement, but this was too slow to work well.
So had to go with small scripts in each of the sheathed sword parts using llSetAlpha to get a faster simultaneous effect.
|
Argent Stonecutter
Emergency Mustelid
Join date: 20 Sep 2005
Posts: 20,263
|
08-21-2009 09:38
I wouldn't sweat it too much, frankly, different people will see the motions and prim parameters changing at slightly different times anyway depending on network traffic.
|