Jump to content

Door Script

Recommended Posts

Hello world !

First of all, I sought my problem in an existing topic but did not find it, so I created one.

So, i've a free door script that work fine, but my problem is that the door is opening in the wrong side. See Gyazo : https://gyazo.com/c359acb9afc0b46a19dc5d067d420495

i would appreciate some help, if someone could tell me what to change in the script it would be cool ! I tried to contact the scripter but no response..

Here is the script :

/***************** Script Data *****************/

integer STATE = FALSE;  
integer LOCKED = FALSE;
float Rotation = 90.0;
float Volume = 1.0;

key CloseSound = "e7ff1054-003d-d134-66be-207573f2b535";
key OpenSound = "cb340647-9680-dd5e-49c0-86edfa01b3ac";
key Loking = "4a23b467-2e4d-d783-3643-6fe1fe4eb179";
key Loked = "378b553c-d511-aab3-d220-c239a6d15ad3";

/***************** Variable *****************/
float LRot;  
key Sound;

        Sound = CloseSound;
        LRot = -Rotation;
    } else {
        if(LOCKED) {
            llTriggerSound(Loked, Volume);
        Sound = OpenSound;
        LRot = Rotation;
    llTriggerSound(Sound, Volume);
    llSetLinkPrimitiveParamsFast(LINK_THIS,[ PRIM_ROT_LOCAL,llEuler2Rot(<0, 0, LRot> * DEG_TO_RAD) * llGetLocalRot()]);

default {
    touch_start(integer n) { llResetTime(); }
    touch_end(integer n){
        if(llGetTime()>1.0 &&  llDetectedKey(FALSE) == llGetOwner()){
            LOCKED = !LOCKED;
            llTriggerSound(Loking, Volume);
        } else Rotate_Door();
    timer() {
        if(STATE) Rotate_Door();

Share this post

Link to post
Share on other sites

I think the problem might lie with the door object itself. I'm guessing that its centre is aligned along the side with the door handle. When making mesh doors (which again I'm guessing this is) it's usual to add an invisible vertex, edge of face to "balance" the door so that its centre lies on the hinge line. I think what's happened here is that the "balancing" component has been added to the wrong side of the door: that is extending out from the side with the handle rather than extending out from the side with the hinges.

  • Like 1
  • Thanks 1

Share this post

Link to post
Share on other sites
1 hour ago, KT Kingsley said:

I think the problem might lie with the door object itself.

@LAHIN MiloI agree with KT.   By default, objects in SL rotate around their centre.  Sometimes this is what you want (a wheel) and sometimes it isn't (a door).    When you don't want the default behaviour, the two solutions are either to offset the object's centre by script or  by adding an invisible vertex as KT describes if it's a mesh or sculpted door or, if you're using a regular prim, by path-cutting it.

Offsetting the object's centre by adding a vertex or path cutting is generally far simpler and gives better visual results than does offsetting the centre by script.    More details of both methods are to be found in this thread: 



Edited by Innula Zenovka
  • Like 2

Share this post

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...