Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Animation prepare for work on click

Jano Debevec
Registered User
Join date: 28 May 2007
Posts: 87
07-10-2008 05:12
I gave walking animation in box. What must I do that animation will work when someone click on box.
Seshat Czeret
Registered User
Join date: 26 May 2008
Posts: 152
07-11-2008 02:26
If I understand you correctly, you have an animation inside a prim (that happens to be a box shape), and you want anyone who clicks on the prim to be animated with your animation.

To achieve that, you need a script.

If you are not a scripter, I would recommend getting a poseball script, and accepting that instead of having people click on the box, they will have to 'sit' on the box. You might be able to find a script that works on a touch, but the poseball script will be far more common.

Actually, if a prim lets you 'sit' as the default action on a left-click, the poseball script is all you need.



If you're a scripter, set the box to 'touch' as the default, and use the following code fragments as the starting point for a script. I may have parameters or actual function names wrong. This is just to get you started.

Edit to add: the formatting has been eaten, too. Sorry about that.


// Global variables
key avatar=NULL_KEY;


// To find out which avatar has clicked on the box
// NOTE: this is a bad script fragment because it's presuming only one person touched the box.
// For anyone else, it's failing silently. Fix that.

touch_start(integer num_touch)
{
avatar = llGetDetectedKey(0);

// Request permission to animate.
llRequestPermissions(avatar,PERMISSION_TRIGGER_ANIMATION);
}

// When you have your permissions
run_time_permissions(integer perm)
{
// Check that you have animation permission.
if (perm & PERMISSION_TRIGGER_ANIMATION)
{
// Run the animation
// NOTE: Replace 'animation_name' with the name of your animation.
llStartAnimation(animation_name);
}
else
{
// You don't have permission to animate the avatar
// Tell them sorry, you can't do it.
llInstantMessage(avatar,"Sorry, animation permission was refused. This animation will not run.";);
}
}
_____________________
My blog: http://seshat-czeret.blogspot.com/
My shop: http://slurl.com/secondlife/Achlya/199/185/102
Imago Aeon
Animation Designer
Join date: 23 Oct 2007
Posts: 65
08-15-2008 05:05
There was no default state, but this script does the job.

Fixed just in case anyone else needed something like this.
CODE
// Global variables
key avatar=NULL_KEY;


// To find out which avatar has clicked on the box
// NOTE: this is a bad script fragment because it's presuming only one person touched the box.
// For anyone else, it's failing silently. Fix that.
default{
touch_start(integer num_touch)
{
avatar = llGetDetectedKey(0);

// Request permission to animate.
llRequestPermissions(avatar,PERMISSION_TRIGGER_ANIMATION);
}

// When you have your permissions
run_time_permissions(integer perm)
{
// Check that you have animation permission.
if (perm & PERMISSION_TRIGGER_ANIMATION)
{
// Run the animation
// NOTE: Replace 'animation_name' with the name of your animation.
llStartAnimation(animation_name);
}
else
{
// You don't have permission to animate the avatar
// Tell them sorry, you can't do it.
llInstantMessage(avatar,"Sorry, animation permission was refused. This animation will not run.");
}
}
}