Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Override Sit animation

Valla Tenk
Registered User
Join date: 20 Feb 2007
Posts: 7
03-20-2008 01:22
Hi

I am trying to create a script which will override the "sit" animation used when an avatar sits on an object.

Basically I actually wnat the avatar to stand (but I need them to "sit" on the object in question to allow camera controls to work). I can get the avatar to sit in front of and looking at the object, but cannot seem to have them stand (as opposed to sit). The first cut script is here...

string ANIMATION = "standing";//anim pose

key avie;

default

{

state_entry()

{

rotation myRot = llEuler2Rot(< 0, 0, 90 * DEG_TO_RAD>;);

llSetCameraEyeOffset(<0,1,0.5>;); // camera position

llSetCameraAtOffset(<0,-10,1>;); // Camera point of focus (where it is looking)

llSitTarget(<0,-1,0>, myRot);

avie = NULL_KEY;

}


changed(integer change)
{

key sitting = llAvatarOnSitTarget();

if (change == CHANGED_LINK)

{

if(sitting != NULL_KEY)

{

avie = sitting;

llRequestPermissions(avie, PERMISSION_TRIGGER_ANIMATION);

}
else
{

llStopAnimation(ANIMATION);
avie = NULL_KEY;

}

}

}

run_time_permissions(integer perms)
{

if ((perms & PERMISSION_TRIGGER_ANIMATION) == PERMISSION_TRIGGER_ANIMATION)

{

llStopAnimation("sit";);

llStartAnimation(ANIMATION);

}

}

}


If any one could point me in the right direction I would appreciate it

Thanks in advance!
Mrc Homewood
Mentor of Randomness
Join date: 24 Feb 2007
Posts: 779
03-20-2008 03:38
try this


CODE

key agentKey = NULL_KEY;
integer permissionResult = FALSE;
string theAnim = "(ANIMATION TO USE)";
string sitText = "(TEXT)";
vector sittingPosition = <-0.1,0,0.7>;

init()
{
llSetSitText(sitText);
llSitTarget(sittingPosition,<0,0,0,1>);
}

default
{
state_entry()
{
init();
}
on_rez(integer rezzed)
{
init();
}
changed(integer change)
{
if (change & CHANGED_LINK)
{
key agent = llAvatarOnSitTarget();
if ( agentKey == NULL_KEY && agent != NULL_KEY )
{
agentKey = agent;
llRequestPermissions(agentKey,PERMISSION_TRIGGER_ANIMATION);
}
else if ( agentKey != NULL_KEY && agent == NULL_KEY)
{
if (permissionResult)
{
llStopAnimation(theAnim);
}
llResetScript();
}
}
}
run_time_permissions(integer perm)
{
if (perm == PERMISSION_TRIGGER_ANIMATION)
{
permissionResult = TRUE;
llStopAnimation("sit");
llStartAnimation(theAnim);
}
}
}
Dylan Rickenbacker
Animator
Join date: 11 Oct 2006
Posts: 365
03-20-2008 03:42
Your script works, I just tested it. Of course, it depends on there being an animation called "standing" present in your poseball's inventory.
Valla Tenk
Registered User
Join date: 20 Feb 2007
Posts: 7
Thanks!
03-20-2008 05:41
Thanks Mrc and Dylan... I will give it another go ;)

Dylan, I did try it with a pose in the object and didn't seem to work tho... maybe I missed something else out :) Didn't help that in order for the camera to work correctly I had to press Esc ...:(

Thanks

Valla
Krista Chaffe
Registered User
Join date: 16 Jun 2007
Posts: 96
03-20-2008 15:47
Thank you so much folks.

I had a problem with animating a sitting avatar. Stopping the "sit" animation fixed it.