Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Multiple sit animations in one chair: how do you do it?

BamBam Sachertorte
floral engineer
Join date: 12 Jul 2005
Posts: 228
10-10-2007 00:42
I want to make a chair with several sit animations. Just for grins I thought that I would allow people to change the animation while sitting by taking over shift-left/right. So it mostly works, with stopping the old animation, starting the new one, and moving the avatar to the new sit target using llSetLinkPrimParams.

But one of the animations has a very different sit target from the rest. If that animation is the initial animation and sit target when the avatar sits down then all of the other animations are way off when I switch to them. If any of the other animations is the initial animation then they all look OK and the odd-ball animation is way off when I switch to it. Do I need to compensate for the sit target when I move the avatar around using llSetLinkPrimParams?
Qie Niangao
Coin-operated
Join date: 24 May 2006
Posts: 7,138
10-10-2007 06:36
Hmmm... well, the prim's llSitTarget becomes irrelevant once the avatar is moved by llSetLinkPrimitiveParams, which operates relative to the root prim of the linkset (not necessarily the scripted prim). Perhaps the question is about the *animation's* base position and rotation, for which one definitely would compensate with llSetLinkPrimitiveParams--but that's really one of the main reasons it's used (so, not sure that's the question)--to be able to incorporate animations with very different built-in offsets.
BamBam Sachertorte
floral engineer
Join date: 12 Jul 2005
Posts: 228
10-10-2007 23:17
LOL. I was using PRIM_POSITION incorrectly. But there is still a difference in avatar position depending on whether it is positioned by the sit target or by llSetLinkPrimParams. I have to add <0.0, -0.05, 0.4> to the position vector that is used for the sit target in the call to llSetLinkPrimParams.

CODE

list gTargets = [
"sit1", <-0.03912, 0.57082, -0.19720>, <-0.49595, -0.59115, -0.48732, 0.40879>,
"sit2", <-0.07814, 0.53751, -0.27184>, <-0.54164, -0.45456, -0.45456, 0.54164>,
"sit3", <-0.14671, 0.51543, -0.60395>, <-0.63695, -0.51770, -0.29567, 0.48873>
];
integer gTargetIndex = 0;

setTarget(integer change)
{
integer liveChange = (llAvatarOnSitTarget() != NULL_KEY) &&
(llGetPermissions() & PERMISSION_TRIGGER_ANIMATION);

change *= 3;
gTargetIndex += change;
if (gTargetIndex >= llGetListLength(gTargets)) gTargetIndex = 0;
if (gTargetIndex < 0) gTargetIndex = llGetListLength(gTargets) + change;

if (liveChange) {
llStopAnimation(ani_name);
}

ani_name = llList2String(gTargets, gTargetIndex);
vector pos = llList2Vector(gTargets, gTargetIndex + 1);
rotation rot = llList2Rot(gTargets, gTargetIndex + 2);
llSitTarget(pos, rot);

if (liveChange) {
llSetLinkPrimitiveParams(3, [PRIM_POSITION, pos + <0.0, -0.05, 0.4>,
PRIM_ROTATION, rot / llGetRootRotation()]);
llStartAnimation(ani_name);
}
}