OsAvatarPlayAnimation

De DigiWiki.

Threat Level = VeryHigh

//Example Usage: 
default { 
  touch_start(integer num) 
  {
    string anim = llGetInventoryName(INVENTORY_ANIMATION, 0);
    osAvatarPlayAnimation(llDetectedKey(0), anim);
  }
}

This function causes an animation to be played on the specified avatar.

The variable animation can be either the name of an animation within the task inventory, or it can be the animation's UUID.

Instead of the name of an animation in the prim's inventory, you can also use the names of the viewer's built-in animations.

osAvatarPlayAnimation does not perform any security checks or request animation permissions from the targeted avatar.

When using this function in an object that requires the user to sit on the object (like a chair,or a poseball), you will need to stop the sit animation by including the following snippet:

changed(integer change)
{
  if (change & CHANGED_LINK)
  {
    key user = llAvatarOnSitTarget();
    osAvatarStopAnimation(user, "sit");
    osAvatarPlayAnimation(user, anim);        
  }
}

Exemple

// ----------------------------------------------------------------
// Example / Sample Script to show function use.
//
// Script Title:    osAvatarPlayAnimation.lsl
// Script Author:   WhiteStar Magic
// Threat Level:    VeryHigh
// Script Source:   
//
// Notes: See Script Source reference for more detailed information
// This sample is full opensource and available to use as you see fit and desire.
// Threat Levels only apply to OSSL & AA Functions
//================================================================
// Inworld Script Line:    osAvatarPlayAnimation(key targetuuid, string anim);
//
// NOTE:  anim can be the Name (if contained in prim) or UUID of the animation
//
default
{
    state_entry()
    {
        llSay(0, "Touch to have Avatar use contained animation with osAvatarPlayAnimation ");
    }
 
    touch_end(integer num)
    {
        string anim = llGetInventoryName(INVENTORY_ANIMATION, 0);
        if(anim == "") 
        {
            llOwnerSay("ERROR: Animation Missing. Please drop an animation in the prim with this script");
            return;
        }
        else
        {
            llOwnerSay("Now Playing "+anim+" animation");
            osAvatarPlayAnimation(llDetectedKey(0), anim);
        }
    }
}
Outils personnels
  • Cette page a été consultée 986 fois.
donate
Google Ads