Jump to content

Trigger animations from an attachment?


anselm Hexicola
 Share

You are about to reply to a thread that has been inactive for 3495 days.

Please take a moment to consider if this thread is worth bumping.

Recommended Posts

I have made an object intended to be "worn" (in this case attached to RH).

I want the avatar to play 2 different animations depending on whether they are sitting or not.

(Yes, I can do that in the Viewer because I have the 2 anims uploaded.)

 I am trying to "automate" the switch between animations in the script belonging to the attachment. 

 IS IT POSSIBLE?

I think I can write this:-

if (llGetAgentInfo(id)& AGENT_SITTING)
			{
				llOwnerSay("you are sitting");
				llStartAnimation(anim1);
			}
			else
			{
				llOwnerSay("you are NOT sitting");
				llStartAnimation(anim2);
			}

 However, I cant put this in the change() event, can I?

Any suggestions?

If it was a poseball-type thing, it would be easier because then you would have a CHANGED_LINK.

 

Link to comment
Share on other sites

Well, there are a couple of standard methods you can use, other than running your animations from a second script.  One is to run your timer with multiplexing.  That is, set it to run with a one second heartbeat and then do some things every second (like checking to see whether you are sitting or not) and other things every ten seconds, or every 60 seconds, or whatever.  The timer really is just like having a clock that ticks, and you count as many ticks as you like before doing different tasks.

The other way is to set up a fake timer, using llSensorRepeat.  Let the repeating sensor fire once a second and only do a chosen task if it doesn't detect its target:

llSensorRepeat("BillThePirate","",AGENT,0.2,PI,1.0);no_sensor(){    if(llGetAgentInfo() & AGENT_SITTING)    {        llStopAnimation("stand");        llStartAnimation("sit");    }    else    {        llStopAnimation("sit");        llStartAnimation("stand");    }}

 

 

 

Link to comment
Share on other sites


Dora Gustafson wrote:

If I remember right you need a
sensor
event handler to go with the
no_sensor
to make it work

It may be very simple though, like:
sensor(){;}

 :smileysurprised:
:)
:smileyvery-happy:

That used to be true, but that restriction was removed sometime last year. It's OK to have a no_sensor event without a dummy sensor event now.

Link to comment
Share on other sites

 llSetAnimationOverride() I was interested in this function you are talking about, so I grabbed and slightly modified the example in the wiki; then did a few tests inworld.

 

string gMySit;default{	state_entry()	{		gMySit=llGetInventoryName(INVENTORY_ANIMATION,0);	}    attach(key id)    {        if ( id ) llRequestPermissions(id , PERMISSION_OVERRIDE_ANIMATIONS);        else if ( llGetPermissions() & PERMISSION_OVERRIDE_ANIMATIONS ) llResetAnimationOverride("ALL");    }    run_time_permissions(integer perms)    {        if ( perms & PERMISSION_OVERRIDE_ANIMATIONS )        {            llSetAnimationOverride( "Sitting", gMySit);        }    }}

 

Maybe I have not fully understood the way this function can be used, but it didn't do what I need (see original post)..

As written above, it seems to substitute the "gMySit " for the "Sitting" (the LL default , I take it?).

All well and good (in my tests) IF gMySit is a full body animation that poses the avatar's legs and torso z_pos.

However take the case where you wish to play say, a "waving" anim that only defines certain joint rotations, eg. the right shoulder,elbow ,hand. Then, (using the above code) the avatar IS sitting according to the Viewer, but (visually) standing and waving.

I want to layer an additional animation on the "Sitting" one.

[And, it may happen that AGENT_SITTING is true but the sitting animation is not necessarily "Sitting".]

Link to comment
Share on other sites

The  llSetAnimationOverride() can override the built-in animations with animations of your choice but
Each built-in can be overridden by one and only one animation
The function do not provide for layered overrides, so if you need that you must do it the old way

[you can override "sitting" with a stand, fly, walk or any animation]

:smileysurprised::):smileyvery-happy:

Link to comment
Share on other sites

You are about to reply to a thread that has been inactive for 3495 days.

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
 Share

×
×
  • Create New...