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
Door Open/Close Depending on Situation
jens Offline
Frictional Games

Posts: 4,093
Threads: 199
Joined: Apr 2006
Reputation: 202
#4
RE: Door Open/Close Depending on Situation

Assuming you have created the area and the callback for entering into the area.

GetSwingDoorClosed() will return a true or false when you use it, so if you do:

//Player enters the area, we check if door is closed or open
void ColliderPlayerInArea(CAN'T RECALL ALL THE STUFF THAT GOES HERE)
{
    //Door is closed so we will creak it open
    if(GetSwingDoorClosed("NameOfDoor") == true)
        CreakOpen();

    //Door is open so we will slam it shut, this is easy.
    else
        SetSwindDoorClosed("NameOfDoor", true, true);
}

//Door was closed, so we add a bunch of timers to give a small amount of force,
//creaking the door open after we disabled some stuff that would interfer
void CreakOpen()
{
    SetSwingDoorDisableAutoClose("NameOfDoor", true);
    SetSwingDoorClosed("NameOfDoor", false, false);

    AddTimer("NameOfDoor", 0.05f, "TimerCreakDoor");
    AddTimer("NameOfDoor", 0.1f, "TimerCreakDoor");
    AddTimer("NameOfDoor", 0.2f, "TimerCreakDoor");
    AddTimer("NameOfDoor", 0.3f, "TimerCreakDoor");
}

//The timer that gives the door a little push, notice that I do not know what a good
//force value is 1 might be too much or too little, and I am not sure of the direction
//so could be -1 or on the Z axis and not on the X axis as in this script.
void TimerCreakDoor(string &in asTimer)
{
    AddPropForce(asTimer, 1, 0, 0, "World");
}
(This post was last modified: 09-18-2010, 11:01 AM by jens.)
09-18-2010, 11:00 AM
Website Find


Messages In This Thread
RE: Door Open/Close Depending on Situation - by jens - 09-18-2010, 11:00 AM



Users browsing this thread: 1 Guest(s)