Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Prim rotates on avatar sit?

Marianne McCann
Feted Inner Child
Join date: 23 Feb 2006
Posts: 7,145
05-25-2007 07:55
I've been workin on a kid's spring animalr riding thing for a couple weeks, and I thought I had it all worked out. Kid sits, the thing starts to rock. Stand up, it stops. Easy peasy.

Then I tried turning the spring animal and setting it toa different orientation. Kid sits, and the animal turns back to the original orientation, instead of staying in place.

Is this an issue with using absolute positioning for the avatar sit? Is there any way around it?

(I'll hafta log in to grab the code, I suppose, or I can provide it in-world if need be)

Mari
_____________________


"There's nothing objectionable nor illegal in having a child-like avatar in itself and we must assume innocence until proof of the contrary." - Lewis PR Linden
"If you find children offensive, you're gonna have trouble in this world :)" - Prospero Linden
Hg Beeks
llGetElement(80);
Join date: 13 Apr 2006
Posts: 134
05-25-2007 08:31
My guess would be that the problem stems from using global (absolute?) rotations for the object itself, and not the avatar.
Marianne McCann
Feted Inner Child
Join date: 23 Feb 2006
Posts: 7,145
05-25-2007 09:14
From: Hg Beeks
My guess would be that the problem stems from using global (absolute?) rotations for the object itself, and not the avatar.


Hmn...

For yuks, here's the script.

Mari


string actionText = "Rock";
string inactionText = "Stop";
integer swingRate = 1; // can only rotate about every 10 seconds actually
float swingDegrees = 0.15;

integer swinging;
integer position;

rotation rotNorm;
rotation rotBack;
rotation rotForth;

key avatar;

init()
{
swinging = FALSE;

rotNorm = llGetRot();
rotBack = rotNorm * <0, swingDegrees, 0, 1>;
rotForth = rotNorm * <0, -(swingDegrees), 0, 1>;

llSetTouchText(actionText);
}

swingNorm()
{
llSetTimerEvent(0.0);
llSetRot(rotNorm);
}

swingBack()
{
llSetRot(rotBack);
position = 1;
}

swingForth()
{
llSetRot(rotForth);
position = 0;
}

default
{
state_entry()
{
init();
llSitTarget(<0.92943, -0.00386, -0.34782>, <0.00000, 0.69466, 0.00000, 0.71934>;);
}

changed(integer change)
{
if(change & CHANGED_LINK)
{
avatar = llAvatarOnSitTarget();

if(llAvatarOnSitTarget() != NULL_KEY ) //sitting
{
llRequestPermissions(avatar,PERMISSION_TRIGGER_ANIMATION);
llStopAnimation("sit";);
llStartAnimation("Ride rocker";);
swinging = TRUE;
swingForth();
llSetTimerEvent(swingRate);
}
else //not sitting
{
llStopAnimation("Ride rocker";);
swinging = FALSE;
}
}

}

timer()
{
if (swinging==FALSE)
{
swingNorm();
}
else if (position==0)
{
swingBack();
}
else
{
swingForth();
}
}
}
_____________________


"There's nothing objectionable nor illegal in having a child-like avatar in itself and we must assume innocence until proof of the contrary." - Lewis PR Linden
"If you find children offensive, you're gonna have trouble in this world :)" - Prospero Linden
Marianne McCann
Feted Inner Child
Join date: 23 Feb 2006
Posts: 7,145
05-28-2007 19:22
For yuks, here's the script.

Mari

CODE

string actionText = "Rock";
string inactionText = "Stop";
integer swingRate = 1; // can only rotate about every 10 seconds actually
float swingDegrees = 0.15;

integer swinging;
integer position;

rotation rotNorm;
rotation rotBack;
rotation rotForth;

key avatar;

init()
{
swinging = FALSE;

rotNorm = llGetRot();
rotBack = rotNorm * <0, swingDegrees, 0, 1>;
rotForth = rotNorm * <0, -(swingDegrees), 0, 1>;

llSetTouchText(actionText);
}

swingNorm()
{
llSetTimerEvent(0.0);
llSetRot(rotNorm);
}

swingBack()
{
llSetRot(rotBack);
position = 1;
}

swingForth()
{
llSetRot(rotForth);
position = 0;
}

default
{
state_entry()
{
init();
llSitTarget(<0.92943, -0.00386, -0.34782>, <0.00000, 0.69466, 0.00000, 0.71934>);
}

changed(integer change)
{
if(change & CHANGED_LINK)
{
avatar = llAvatarOnSitTarget();

if(llAvatarOnSitTarget() != NULL_KEY ) //sitting
{
llRequestPermissions(avatar,PERMISSION_TRIGGER_ANI MATION);
llStopAnimation("sit");
llStartAnimation("Ride rocker");
swinging = TRUE;
swingForth();
llSetTimerEvent(swingRate);
}
else //not sitting
{
llStopAnimation("Ride rocker");
swinging = FALSE;
}
}

}

timer()
{
if (swinging==FALSE)
{
swingNorm();
}
else if (position==0)
{
swingBack();
}
else
{
swingForth();
}
}
}
_____________________


"There's nothing objectionable nor illegal in having a child-like avatar in itself and we must assume innocence until proof of the contrary." - Lewis PR Linden
"If you find children offensive, you're gonna have trouble in this world :)" - Prospero Linden
Anti Antonelli
Deranged Toymaker
Join date: 25 Apr 2006
Posts: 1,091
05-28-2007 23:06
The problem is you're setting rotNorm in init(), which is only called from state_entry(), which only runs when the script is started or reset. So rotNorm never gets updated, it stays at the value it was when you last reset the script.

It might be as simple as setting rotNorm to llGetRot() again right in your swingForth function, or in the changed() event handler, so you get the current rotation just as the rider sits down.