Introduction
This article describes the process used for creating a door that can be locked and unlocked through the use of the
func_button,
trigger_relay, and
multisource entities. This type of setup is useful for creating a situation where the player must accomplish some task (turning on a power grid, disabling a security system, etc) before proceeding to the next area of a level.
Setup
The image below shows the entity layout in the editor's 3D view.
The Door
The first thing to do is build the door. In the example map, I've used a
func_door_rotating. Aside from the normal properties, I've chosen the "latch locked" Locked Sounds and given it a Master value of "door_master". This makes the door openable only when the "door_master"
multisource (added below) is in an On state. Trying to open the door when the "door_master"
multisource is in an Off state will play the "latch locked" sound.
The Button
The button is a simple
func_button. The Target of the button is a
trigger_relay named "door_master_r" (added below). In the flag properties of the
func_button, the "Don't Move" and "Toggle" flags are both enabled. It is not entirely necessary to enabled the "Toggle" flag, as it won't effect the operation of the door, but it does allow for the correct texture to be displayed on the button, since a togglable texture is being used.
The Relay
Due to the behavior of a toggled
func_button, it is necessary to put a
trigger_relay between the
func_button and
multisource entities. Set the Name to "door_master_r". Set the Target to the name of the
multisource -- "door_master" in this example. Also, set the Trigger State property to "Toggle". When the relay is activated, it will set the
multisource entity's state to the opposite of it's current state, ie: On -> Off, or Off -> On.
The Master
Last and most important is the
multisource entity. Although it's the most important entity in this equation, it's also the easiest to setup. Simply give it a Name. This example uses a name of "door_master". The multisource acts as the door's locking mechanism.
Why It Works
When you start the level, the
multisource is in it's default
Off state. Since the door uses the
multisource as a master, the door is also in an Off state. When you attempt to use the door, you will get some type of
locked sound (if you've set the Locked Sound property of the door). Pressing the button will make the
trigger_relay activate the
multisource, toggling it (and the door) to an
On state. Pressing the button again will toggle it back off. And so on and so forth.
Notes
This example used a
trigger_relay activated by a
func_button to toggle the
multisource entity. In practice, though, any entity that is capable of activating an event can be used to activate the
multisource. Things like
trigger_multiple,
trigger_once, picking up items or weapons - these are all possible triggers for the
multisource. Note that in these cases, it is not necessary to use the
trigger_relay -- you can target the
multisource directly.
This technique can be used with any entity that takes a
multisource entity for a Master. Try modifying the example map - give the
func_button a Master value of "button_master". Create a
multisource with a name of "button_master", and create an
item_security somewhere in the same room as the starting player. In the
item_security properties, set the Target to "button_master"
This article was originally published on the
Valve Editing Resource Collective (VERC).
TWHL only archives articles from defunct websites. For more information on TWHL's archiving efforts, please visit the
TWHL Archiving Project page.