Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

How to run animations in sequence?

Suzhanna Rossini
Shopaholic
Join date: 2 Apr 2007
Posts: 109
12-30-2007 02:19
How can I make a script run animations in sequence? I need a seamless animation from several animations since the total is too long to fit in one.
I haven't seen any obvious way to "know" when one animation ends, and when to start the next.
_____________________
When I'm hot, I'm cooking - When I'm not, I'm a bitch..
Jay Karlfeldt
Happy Scripter
Join date: 4 Nov 2005
Posts: 51
User the Timer....
12-30-2007 02:57
Find the length of each animation and use llSetTimerEvent(Animation_Length) to change to next animation and reset the timer for the length of the next animation in the chain.

Have used this to bend down, pick up a dog and start stroking it, then on chat command bend down put it down and stand up again.
Deanna Trollop
BZ Enterprises
Join date: 30 Jan 2006
Posts: 671
12-30-2007 07:06
But note that the first time a particular client tries to play an animation, it will have to download it to its own cache. Depending on lag, this could cause a noticeable delay on the first play, but once the anims are cached, they should play more-or-less immediately when requested.

One way around this is to "preload" the anim(s) by playing and immediately stopping them, pausing for some amount of time, then "actually" playing the sequence. Testing this can be annoying, though, since to test a true "first time" scenario requires you clear your cache and relog.
Suzhanna Rossini
Shopaholic
Join date: 2 Apr 2007
Posts: 109
12-31-2007 21:16
This is bad news....
As I understand it, I need to know the length of each animation pretty exactly in beforehand? I was hoping for a more general solution to somehow have the script figure out either the length, or even get noticed of the end of the animations to start the next in the sequence.

Oh well, I guess I have to rethink the entire idea..
_____________________
When I'm hot, I'm cooking - When I'm not, I'm a bitch..
RJ Source
Green Sky Labs
Join date: 10 Jan 2007
Posts: 272
01-01-2008 07:15
The less efficient/elegant way, but without knowing the animation length, is to play the animation, and at the same time have a timer running a couple times a second, calling llGetAnimationList, and checking whether or not the animation is still playing. When it is not, you start the next one.
Ordinal Malaprop
really very ordinary
Join date: 9 Sep 2005
Posts: 4,607
01-01-2008 07:21
Yes, that would work, though the transition between animations would be a bit obvious. In fact you really want to overlap them slightly, to exploit the "blending" between different animations.

If you have a basic "background" pose playing all the way through, with a lower priority to the main ones, this would help cover up the gaps. You might need more than one if the basic pose changes radically e.g. standing up for a bit and then kneeling down.

If it is only a few of them and they aren't going to change I would simply fix the timing by trial and error, observing what looks the best. I frequently do this with animations that I made myself and know the exact length of - it can be hard to tell what they look like in combination and precisely how long LSL will take to move between effects (0.1s can be crucial to the look of a sequence of animations). So even knowing what is going on I usually have to edit the timing manually anyway.
_____________________
http://ordinalmalaprop.com/forum/ - visit Ordinal's Scripting Colloquium for scripting discussion with actual working BBCode!

http://ordinalmalaprop.com/engine/ - An Engine Fit For My Proceeding, my Aethernet Journal

http://www.flickr.com/groups/slgriefbuild/ - Second Life Griefbuild Digest, pictures of horrible ad griefing and land spam, and the naming of names
Suzhanna Rossini
Shopaholic
Join date: 2 Apr 2007
Posts: 109
01-01-2008 23:41
Thanks for the ideas and tips!
I'll do some experimenting with it and see if I can come up with something that works for the ideas I have in mind.. ;)

Have a great new year! ;)
_____________________
When I'm hot, I'm cooking - When I'm not, I'm a bitch..