Sound sensitive trigger
This tutorial will explain the process of making a trigger that will detect sound levels in the surrounding area and go off.
First of all, you need a small area for this example. The area for this tutorial is a small courtyard, as shown on the right.
Setting up the necessary entities
We need something for the microphone to detect from. An
info_target is what we will be using. Call it
microphone1. In your map, it can be called anything you like.
Then, create an
env_microphone. This is the entity that will control the sound output level. Give it the following properties:
Classname : env_microphone
- Name : speaker In your map again, this can be anything at all.
- Measure Target : microphone1 Make sure this is the name of your
info_target, otherwise the
env_microphonewon't do its sound checks correctly.
- Sensitivity : 2 This should allow you to not be detected by crouching, but will detect you when you run or shoot.
- Maximum hearing range : 512 This is the distance in units the
- Spawnflags :
- Hears combat sounds
- Hears world sounds
- Hears player sounds
- Hears bullet impacts
- Hears explosions
Now we need a
logic_compare to test the sound levels. We need the following parameters for it:
Classname : logic_compare
- Name : spvol Our entity's name again, this entity checks the volume of the microphone and can trigger things.
- Initial value : 0 This is what the
logic_comparewill compare all values to, and can trigger an output depending on various states.
- Compare value : 0.5 This is the trigger level to trigger things from the sound level of the
Now we need to set up some of the entity I/O on our
env_microphone. Add a new output to our
env_microphone with the following options:
|My Output||Target Entity||Target Input||Parameter||Delay||Only Once|
Making the trigger
The final step now is to set up the output of the
logic_compare to trigger something. This can be open a door, turn on a light, break a rope, anything that can take an entity I/O input. In this case we will rig up an alarm.
- OnGreaterThan: This gets triggered when the sound level is past the trigger level.
- OnLessThan: This gets triggered when the sound level is under the trigger level.
Now you should have a working sound sensitive trigger!