You are viewing an older revision of this wiki page. The current revision may be more detailed and up-to-date.
Click here to see the current revision of this page.

Doors. Who doesn't love them? They can come in all shapes and sizes : standard rotating , sliding , even hexagonal doors! But have you ever had that time where your doors just don't cooperate? One closing before the other? One being completely out of sync? Well , here is a relatively simple way to fix that.
## The Problem

The problem is caused by two ( or more ) doors of different lengths moving at different speeds.Because they are different lengths , the shorter / faster door will close before the other and leave an OCD-inducing time gap.

To fix this problem , we need to use some maths to find the speeds at which doors will shut at the same time.## The Solution

The root of the solution to this problem is the incredibly simple equation :

It allows you to figure out the duration , speed and distance an object moves or takes to move if you know the other 2 variables.

We will be using this derivative equation in this tutorial to do our work:## The Method

For each func_door:

Find the length of your door in the direction it is moving , and the Lip value you have put in , if there is any.

Decide on a duration for the door - 5 seconds , 1 second , maybe even half of a second## Example

In this example I've created an "odd door" , that being that the whole door compromises of two separate doors with different lengths. The geometry is as shown: Now as the lengths of the top section and bottom section are different , when both doors open , the bottom door will close before the top door closes. Unless you have a complex entity setup with the doors set to toggle , they won't open and close at the same time ( or arrive at the same time , for that matter ). From the editor , we can see that our first door is 96 units high. To complicate this further , we have set the lip of this door to 16.

The bottom door is 48 units high , with no lip.

**NOTE : It isn't always the height used , It's only because this doors moves vertically. The distance measured is relative to the direction.**

We want our chunky door to take a nice 2 seconds to open up, so here we input these values into our two equations

**BLUE DOOR**
**RED DOOR**

To fix this problem , we need to use some maths to find the speeds at which doors will shut at the same time.

`D = S*T`

If you haven't seen this before , this is known as the DST formula ( Distance , Speed , Time ).It allows you to figure out the duration , speed and distance an object moves or takes to move if you know the other 2 variables.

We will be using this derivative equation in this tutorial to do our work:

`S = (D-LIP)/T`

You can also use this equation to find out the time a door will take to open in case some variables are unknown to you.
`T = (D-LIP)/S`

Find the length of your door in the direction it is moving , and the Lip value you have put in , if there is any.

Decide on a duration for the door - 5 seconds , 1 second , maybe even half of a second

`S = (D-LIP)/T`

For each func_door, divide the found length minus the door's lip by your chosen time. Set the func_door's speeds to these value, and both doors should shut at the same time.
The bottom door is 48 units high , with no lip.

We want our chunky door to take a nice 2 seconds to open up, so here we input these values into our two equations

```
D = 96
LIP = 16
T = 2
S = (D-LIP)/T
S = (96-16)/2
S = 80/2
S = 40
```

```
D = 48
LIP = 0
T = 2
S = (D-LIP)/T
S = 48/2
S = 24
```

When I plug in 40 as the speed of the blue door, and 24 as the speed of the red door, the two will now open and shut at the exact same time. Piece of cake!
- Categories
- Tutorials
- Intermediate Tutorials
- Goldsource Tutorials

You must log in to post a comment. You can login or register a new account.

Nice Tut - Simple, easy to follow.

I used to not care about door timings, but now that i dont have to think for myself, i'm gonna apply it

Anyway, god work.