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 :
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
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
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.
Example
In this example I've created an "odd door" , that being that the whole door compromises of two separate doors with different lengths.
Sweet and simple.
The geometry is as shown:
The dominant door (blue) and recessive (red) 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 ).
This is shown at the bottom right corner of the Hammer editor ; it displays the dimensions of the selected object.
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
D = 96
LIP = 16
T = 2
S = (D-LIP)/T
S = (96-16)/2
S = 80/2
S = 40
RED DOOR
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!
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.