Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Door rotates incorrectly when parent rotated

Tyg Jarrico
Registered User
Join date: 29 May 2005
Posts: 98
01-09-2006 09:18
I have a cabinet that is the parent of two doors (created with cut). I used a basic door script from either the forums or the WIKI.

The doors open and close correctly. However, the minute I rotate the entire cabinet and try opening doors, they either over or underrotate (as if they were adding or subtracting the cabinet rotation.)

Is there a bit of code I have to add so they open and close properly each time?

Thanks.
BamBam Sachertorte
floral engineer
Join date: 12 Jul 2005
Posts: 228
01-09-2006 11:26
Does your script use llSetLocalRot() or llSetPrimitiveParams() to rotate the doors? If you are using llSetPrimitiveParams() then you need to divide by the root prim's rotation.
Paolo Portocarrero
Puritanical Hedonist
Join date: 28 Apr 2004
Posts: 2,393
01-09-2006 11:28
Make sure the root prim is not rotated: X, Y and Z should be zero.
_____________________
Facades by Paolo - Photo-Realistic Skins for Doods
> Flagship store, Santo Paolo's Lofts & Boutiques
> SLBoutique
Tyg Jarrico
Registered User
Join date: 29 May 2005
Posts: 98
01-09-2006 17:08
Here is the script I'm using:

integer dooropen;

default
{
state_entry()
{
llSay(0, "Hello, Avatar!";);
}

touch_start(integer total_number)
{

if (dooropen == FALSE)
{
llTriggerSound("Door open", 0.5);
rotation rot = llGetRot();
rotation delta = llEuler2Rot(<0, 0, -PI_BY_TWO>;);
rot = delta * rot;
llSetRot(rot);
dooropen = TRUE;
}
else
{
llTriggerSound("Door close", 0.5);
rotation rot = llGetRot();
rotation delta = llEuler2Rot(<0, 0, PI_BY_TWO>;);
rot = delta * rot;
llSetRot(rot);
dooropen = FALSE;
}
}
}
Ben Bacon
Registered User
Join date: 14 Jul 2005
Posts: 809
01-10-2006 03:53
Replace the two llSetRot calls with llSetLocalRot.
(don't worry about llGetRot - it is automatically local in child prims)*EDIT* no it isn't!!
Tyg Jarrico
Registered User
Join date: 29 May 2005
Posts: 98
01-10-2006 06:05
I replaced them and I'm still getting the same problem :(
Eloise Pasteur
Curious Individual
Join date: 14 Jul 2004
Posts: 1,952
01-10-2006 09:29
Whilst I would have done it Ben's way, try replacing the llGetRot() calls with llGetLocalRot() too.
Tyg Jarrico
Registered User
Join date: 29 May 2005
Posts: 98
01-10-2006 10:00
It's working perfectly now. Thanks very much.
Ben Bacon
Registered User
Join date: 14 Jul 2005
Posts: 809
01-11-2006 02:00
From: Eloise Pasteur
Whilst I would have done it Ben's way, try replacing the llGetRot() calls with llGetLocalRot() too.
whoopsy - ty El - I was confusing myself with llSetPos