Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Dumb question about running an animation from a script

Leyah Renegade
Live Musician
Join date: 2 Nov 2006
Posts: 125
04-15-2007 11:27
Hey all,

I'm making my first object that includes a scripted animation. In the default state, I set a sit target and then the next line is llStartAnimation("scriptname";). I've included the animation in the root prim, my default script compiles successfully, and the llSitTarget command works... but then the animation doesn't start. What am I missing?
Newgate Ludd
Out of Chesse Error
Join date: 8 Apr 2005
Posts: 2,103
04-15-2007 11:39
From: Leyah Renegade
Hey all,

I'm making my first object that includes a scripted animation. In the default state, I set a sit target and then the next line is llStartAnimation("scriptname";). I've included the animation in the root prim, my default script compiles successfully, and the llSitTarget command works... but then the animation doesn't start. What am I missing?


First do you actually have an animation called scriptname?
Secondly you probably dont really want to start the animation in state_entry, who is it going to be animating? The animation should be in responce to either a touch or a sit (from your texts I'd say its a sit.)
You also dont appear to have requested animation permissions?
Look here or herefor examples.
Leyah Renegade
Live Musician
Join date: 2 Nov 2006
Posts: 125
04-15-2007 11:49
From: Newgate Ludd
First do you actually have an animation called scriptname?


No, I substituted the actual name of my script.

From: someone

Secondly you probably dont really want to start the animation in state_entry, who is it going to be animating? The animation should be in responce to either a touch or a sit (from your texts I'd say its a sit.)


Yes, I want it to animate anybody who sits on it.

From: someone

You also dont appear to have requested animation permissions?


Hmm... doesn't that open the dialog that asks if the object has permission to animate your avatar? I see a LOT of scripted objects that don't do that, and I would rather not.
Leyah Renegade
Live Musician
Join date: 2 Nov 2006
Posts: 125
04-15-2007 12:10
OK, one of the threads you linked to gave me the answer, thank you!

Now it works but it seems to have messed up my sit target setting... where should I call llSitTarget so that it works again?

This is very bizarre, if I just leave the state_entry intact with the llSitTarget command in it, my sit target works. And once I am sitting, if I play the animation manually it works. But once I add the function to call the script... my av sits in the wrong place. :(
Ravanne Sullivan
Pole Dancer Extraordinair
Join date: 10 Dec 2005
Posts: 674
04-15-2007 12:41
If you want help with the script it would be helpful if you posted it here. Your description is too vague to be able to tell where and why you are having this problem.
_____________________
Ravanne's Dance Poles and Animations

Available at my Superstore and Showroom on Insula de Somni
http://slurl.com/secondlife/Insula de Somni/94/194/27/
Leyah Renegade
Live Musician
Join date: 2 Nov 2006
Posts: 125
04-15-2007 12:48
OK here is the complete contents of the script:

CODE
key avatar ;

default
{
state_entry()
{

llSitTarget(<-0.20829, -0.04460, 0.35052>, <0.00001, 0.00000, -0.99996, 0.00892>);

}

on_rez(integer num) { llResetScript(); }

changed(integer change)
{
// The object's sit target has been triggered
if (change & CHANGED_LINK)
{

avatar = llAvatarOnSitTarget();
llRequestPermissions(avatar,PERMISSION_TRIGGER_ANIMATION);
llStopAnimation("sit");
llStartAnimation("drumshh");

}
}


}



Note that if I comment out everything below the state_entry function, the sit target works. I can also run my animation manually (from my inventory) while sitting, and it doesn't change the sit target. But as soon as I add the changed() function in, it works so far as starting the animation goes, but I end up floating above my object.

I also tried commenting on the on_rez() line, thinking maybe a script reset was messing up the sit target. Same result.
Kenn Nilsson
AeonVox
Join date: 24 May 2005
Posts: 897
04-15-2007 13:09
It seems that the default 'hip' position of your sit animation is different from the default 'hip' position of the standard SL sit animation.

All animations maintain their in-world position by hip-position. Since many hip-positions vary throughout different animations/poses, it is common to appear that you are floating when using one sit pose and sunk into the chair when using another.

(So the solution to your problem is to change the sit-target around until you stop floating)
_____________________
--AeonVox--

Computer games don't affect kids; I mean if Pac-Man affected us as kids, we'd all be running around in darkened rooms chasing ghosts, eating magic pills, and listening to repetitive, addictive, electronic music.
Leyah Renegade
Live Musician
Join date: 2 Nov 2006
Posts: 125
04-15-2007 13:16
From: Kenn Nilsson
It seems that the default 'hip' position of your sit animation is different from the default 'hip' position of the standard SL sit animation.


Yes it probably is... but I thought I had already corrected for that. If that's what the problem is, why is it that I can sit on the object and start the animation from my inventory and it works?

EDIT: Ahhh I see what's going on. If I don't stop the default sit animation but simply start mine and let it override the default, it works, since I didn't change the hip position in my animation to a sitting height. No big deal to leave it that way, but I guess in the future I'll lower the position of the hip so that it matches the SL sit... does anybody know what that coordinate is? Hard to guess when we can't animate in-world. :)
Kenn Nilsson
AeonVox
Join date: 24 May 2005
Posts: 897
04-15-2007 13:49
You can actually download the default sit animation from the SL website from the same place you download the SL Avatar Mesh for Poser. That should give you a correct starting hip-placement.
_____________________
--AeonVox--

Computer games don't affect kids; I mean if Pac-Man affected us as kids, we'd all be running around in darkened rooms chasing ghosts, eating magic pills, and listening to repetitive, addictive, electronic music.
Leyah Renegade
Live Musician
Join date: 2 Nov 2006
Posts: 125
04-15-2007 14:07
Thanks very much Kenn!
Leyah Renegade
Live Musician
Join date: 2 Nov 2006
Posts: 125
04-15-2007 19:08
OK got everything straight now... one last dumb question... it seems the animation is a little inconsistent in that every once in awhile, it doesn't stop when I (or someone else) stand up. Is this an SL bug or is there something I can do to fix it?

Also, it seems that the hand poses in SL are inconsistent. You can choose when you upload, to have the hands in a fist, etc. and that works with a standing animation, but when you sit, it seems the hands spread out again a lot of the time (but not always). An SL bug I assume?
Kenn Nilsson
AeonVox
Join date: 24 May 2005
Posts: 897
04-15-2007 19:59
It's probably overkill...but you can make sure that your animation never sticks by plugging the below (or similar) code into your animation script:

CODE


list anims = llGetAnimationList(ksit);
integer l = llGetListLength(anims);
integer x;
for(x = 0; x < l; x++) llStopAnimation(llList2Key(anims, x));



Essentially...we get the list of animations currently being played for the person who was sitting and stop all of them. It's a surefire way to get rid of unwanted animations.

Note that I don't define ksit for you...I don't know what your current script looks like. You'll need to make sure ksit = the UUID of sitting avatar.
_____________________
--AeonVox--

Computer games don't affect kids; I mean if Pac-Man affected us as kids, we'd all be running around in darkened rooms chasing ghosts, eating magic pills, and listening to repetitive, addictive, electronic music.