Jump to content

Start and Stop animation in contents in attached mesh


SerenaPufnstuf
 Share

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

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

Recommended Posts

If you want to play an extra animation, in addition to whatever walk/run cycle your character plays, you're going to want to look at some old Animation Override scripts -- ones that don't use the llSetAnimationOverride() function. The fundamentals go something like this:
 

// Set these to your custom values.
string cMySkateAnimName = "my skating animation";
float cCheckTime = 0.5;    // time delay between checks, in seconds


key gOwner;
integer gPlayingMySkates;

default
{
    state_entry()
    {
        gOwner = llGetOwner();
        gPlayingMySkates = FALSE;
        llRequestPermissions(gOwner, PERMISSION_TRIGGER_ANIMATION);
        llSetTimerEvent(cCheckTime);
    }
    
    timer() {
        string systemAnimation = llGetAnimation(gOwner);
        integer IAmMoving;
 
        if (systemAnimation == "Walking" || systemAnimation == "Running")
            IAmMoving = TRUE;
        else
            IAmMoving = FALSE;
        if (IAmMoving && !gPlayingMySkates) {
            llStartAnimation(cMySkateAnimName);
            gPlayingMySkates = TRUE;
        } else if (!IAmMoving && gPlayingMySkates) {
            llStopAnimation("my skating animation name");
            gPlayingMySkates = FALSE;
        }
    }

}


If you want to play your custom animation instead of walking/running, that's a basic AO. There are plenty of free, customizable ones on the Marketplace and in-world. I use a ZHAO, which is really old-school but still works.

Link to comment
Share on other sites

oops spoke too soon lols

[01:06] Script trying to trigger animations but PERMISSION_TRIGGER_ANIMATION permission not set
[01:06] Script trying to stop animations but PERMISSION_TRIGGER_ANIMATION permission not set

It actually works in-world but receive the above error message.

Edited by SerenaPufnstuf
extra info
Link to comment
Share on other sites

12 hours ago, SerenaPufnstuf said:

oops spoke too soon lols

[01:06] Script trying to trigger animations but PERMISSION_TRIGGER_ANIMATION permission not set
[01:06] Script trying to stop animations but PERMISSION_TRIGGER_ANIMATION permission not set

It actually works in-world but receive the above error message.

Heh. That's not a totally robust, 100% unbreakable script. I was just giving the core functionality -- and kind of off the cuff. Things like manual animation resetting and laggy sim crossings might get it out of sync. :( Also, I don't think I accounted for taking the object off and putting it back on.  Replacing the whole state_entry() function with this should hopefully fix that:

    attach(key id)
    {
        if (id == NULL_KEY) {
            llSetTimerEvent(0.0);
        } else {
            gOwner = id;
            gPlayingMySkates = FALSE;
            llRequestPermissions(gOwner, PERMISSION_TRIGGER_ANIMATION);
            llSetTimerEvent(cCheckTime);
        }
    }

I won't have time to seriously check things until later.

P.S. If it's for an object that other people can get and put on it'll need to be even more complicated and I've never looked into that.

Edited by Quarrel Kukulcan
Link to comment
Share on other sites

This fixes the animation name bug (which was my fault) and follows better permission timing guidelines from the scripting wiki.
 

// Set these to your custom values.
string cMySkateAnimName = "my skating animation";
float cCheckTime = 0.5;    // time delay between checks, in seconds

key gOwner;
integer gPlayingMySkates;

default
{
    attach(key id)
    {
        if (id == NULL_KEY) {
            llSetTimerEvent(0.0);
        } else {
            gOwner = id;
            gPlayingMySkates = FALSE;
            llRequestPermissions(gOwner, PERMISSION_TRIGGER_ANIMATION);
        }
    }

    run_time_permissions(integer perm)
    {
        if (perm & PERMISSION_TRIGGER_ANIMATION) {
            llSetTimerEvent(cCheckTime);
        }
    }

    timer()
    {
        string systemAnimation = llGetAnimation(gOwner);
        integer IAmMoving;
 
        if (systemAnimation == "Walking" || systemAnimation == "Running")
            IAmMoving = TRUE;
        else
            IAmMoving = FALSE;
        if (IAmMoving && !gPlayingMySkates) {
            llStartAnimation(cMySkateAnimName);
            gPlayingMySkates = TRUE;
        } else if (!IAmMoving && gPlayingMySkates) {
            llStopAnimation(cMySkateAnimName);
            gPlayingMySkates = FALSE;
        }
    }

}

 

Link to comment
Share on other sites

You are about to reply to a thread that has been inactive for 1245 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...