WiseSaloonDoors: Saloon Doors
This tutorial was originally created by wisemx. It was originally posted on SDKnuts.net.
Introduction
- Prop doors
func_door
s- Toggleable doors
- Brush and entity based doors of many types like
func_movelinear
.
The principles illustrated in this project are:
- Hinges for brush based doors.
- Creating doors that swing freely and return the starting position.
- Doors that can be shot from their hinges.
The doors in this project are func_physbox
. func_physbox
is a brush based entity that simulates Source engine physics. They are not the ideal candidate for all your brush based doors. They are however the best solution for swinging doors like these. We need these doors to swing open when pushed by the player. We don’t want them to appear to be stuck at any time. We want them to return to a resting point but not instantly. Most of your doors will have their own hinge. These func_physbox
doors require that we create a constraint system. phys_hinge
is the constraining entity we will use for these doors. We are also going to use a phys_spring
. phys_spring
is another entity that simulates Source engine physics. It does a very good job of creating a stretching effect. For these doors it will act like a rubber band that connects them. This is what will cause the doors to return to a resting position.
Creation
Add a phys_hinge
to the center of each door's hinged edge and make your adjustments.
Notice in the image above the phys_hinge
was placed evenly over the meeting area of the door and wall. Also notice that the phys_hinge
was adjusted in the side 2D viewport to create a larger hinged area. The white target illustrated in the side 2D viewport is also the blue ball in the 3D viewport. In this project the short wall sections were converted to func_brush
so they could be named and then used as the phys_hinge
’s Entity 1 property. This isn’t always necessary but when needed func_brush
is perfect for the job.
Placing the phys_spring
is similar. I’ve placed it in the center of Door2
and have adjusted the length of the spring with the Hammer Helpers until the white target was in the center of Door1
.
I've also added outputs to the doors so when OnDamaged
fires, they will Break
the hinges. I've also flagged the doors to Only Break on Trigger, so they won't break until told to.
The only properties you will need to adjust besides the constraint points for the spring and hinges are the Damping and Spring Constant properties for the phys_spring
.
These are the properties I used for this phys_spring
.
- Name: spring01
- Entity 1: door02
- Entity 2: door01
- Spring Length: 0
- Spring Constant: 900
- Damping Constant: 7.0
- Relative Damping Constant: 0.9
- Break on Length: 0
- Flags: Force only on Stretch