Facebook Twitter YouTube Frictional Games | Forum | Privacy Policy | Dev Blog | Dev Wiki | Support | Gametee


Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Making a door open slowly [SOLVED]
Linus Ågren Offline
Senior Member

Posts: 309
Threads: 58
Joined: Jan 2011
Reputation: 5
#1
Making a door open slowly [SOLVED]

How do you make a door open slowly and not slam up? I've tried with a few PropImpulses but they seem to be quite rough. I looked at the script in the first level where the door opens, and I saw some PropForces but I can't get it to work. So how do you get a door to slowly open? Smile

Creator of The Dark Treasure.
(This post was last modified: 02-18-2011, 10:25 AM by Linus Ågren.)
02-17-2011, 11:29 PM
Website Find
Vradcly Offline
Member

Posts: 100
Threads: 6
Joined: Jan 2011
Reputation: 0
#2
RE: Making a door open slowly

Maby if you send a propforce on a collideable entity like a barrel or something that rolls into the door and by its force in turn makes the door open slowly. And make the barrel invisible by removing its "entity connection". I dont know if this works, just a theory I came up with now...
02-18-2011, 12:40 AM
Find
Acies Offline
Posting Freak

Posts: 1,643
Threads: 60
Joined: Feb 2011
Reputation: 73
#3
RE: Making a door open slowly

nah. I've just made one. Add a timer linked to a propimpulse. something like (this is not correct code, just my general idea from memory):

void PushDoorTimer
{
if getlocalvarint("TickX") == 40)
{
return;
}
else
AddPropImpulse("door", 0.0f, 0.0f, 0.04f, "");
// 0.04f (around this force makes it open slowly regarding the timer)
SetSwingDoorDisableAutoClose("door", false);
AddTimer("PushDoor", 0.1f, "PushDoorTimer");
AddLocalVarInt("TickX", 1);
}

This script will give the door a small push every 0.1 second for a total of 4 seconds. The swingdoordisableautoclose is important, since such small forces wouldn't open the door otherwise. If you are still having trouble I could copy --> paste the script for you tomorrow.

[Image: mZiYnxe.png]


02-18-2011, 03:31 AM
Find
Linus Ågren Offline
Senior Member

Posts: 309
Threads: 58
Joined: Jan 2011
Reputation: 5
#4
RE: Making a door open slowly

Okay, I fixed the errors, but the door won't push itself open.
The script now looks like:
void DoorOpenTimer(string &in asTimer)
{
    if (GetLocalVarInt("TickX") == 40){
        return;
    }
    else
        AddPropImpulse("cellar_wood01_1", 0.0f, 0.0f, 0.04f, "");
        // 0.04f (around this force makes it open slowly regarding the timer)
        SetSwingDoorDisableAutoClose("cellar_wood01_1", false);
        AddTimer("PushDoor", 0.1f, "DoorOpenTimer");
        AddLocalVarInt("TickX", 1);
}

but it doesn't work. The door remains closed.

Creator of The Dark Treasure.
(This post was last modified: 02-18-2011, 08:35 AM by Linus Ågren.)
02-18-2011, 07:32 AM
Website Find
jens Offline
Frictional Games

Posts: 4,093
Threads: 199
Joined: Apr 2006
Reputation: 202
#5
RE: Making a door open slowly

Add SetSwingDoorClosed("cellar_wood01_1", false); //<- look up the exact function incase I rememeber incorrectly

And then change the order of things to be:

SetSwingDoorDisableAutoClose("cellar_wood01_1", false);
SetSwingDoorClosed("cellar_wood01_1", false);
AddPropImpulse("cellar_wood01_1", 0.0f, 0.0f, 0.04f, "");
02-18-2011, 07:35 AM
Website Find
Linus Ågren Offline
Senior Member

Posts: 309
Threads: 58
Joined: Jan 2011
Reputation: 5
#6
RE: Making a door open slowly

(02-18-2011, 07:35 AM)jens Wrote: Add SetSwingDoorClosed("cellar_wood01_1", false); //<- look up the exact function incase I rememeber incorrectly

And then change the order of things to be:

SetSwingDoorDisableAutoClose("cellar_wood01_1", false);
SetSwingDoorClosed("cellar_wood01_1", false);
AddPropImpulse("cellar_wood01_1", 0.0f, 0.0f, 0.04f, "");

Alright, I changed the script to:
void DoorOpenTimer(string &in asTimer)
{
    if (GetLocalVarInt("TickX") == 40){
        return;
    }
    else
    SetSwingDoorClosed("cellar_wood01_1", false, true);
    SetSwingDoorDisableAutoClose("cellar_wood01_1", false);

    AddPropImpulse("cellar_wood01_1", 0.0f, 0.0f, -0.04f, "");  //I got negative here as my door opens towards me on the Z axis (which gives a lower value when moving the door towards me.
    
    AddTimer("PushDoor", 0.1f, "DoorOpenTimer");
    AddLocalVarInt("TickX", 1);
}

Now the door bugs up and opens/closes very very little, spamming the open & close sound. I tried adding more PropImpulse to the door, but with no luck.

Edit: I found the problem. I changed:
    SetSwingDoorDisableAutoClose("cellar_wood01_1", false);
to:
    SetSwingDoorDisableAutoClose("cellar_wood01_1", true);
Thanks! Big Grin

Creator of The Dark Treasure.
(This post was last modified: 02-18-2011, 11:24 AM by Linus Ågren.)
02-18-2011, 07:55 AM
Website Find




Users browsing this thread: 2 Guest(s)