Sound sensitive trigger

From Valve Developer Community
Revision as of 19:12, 14 January 2006 by Ts2do (talk | contribs)
Jump to navigation Jump to search


In this tutorial, making a trigger that will detect and trigger depending on the sound levels in the surrounding area will be explained. Right, lets get stuck in. First of all, make yourself a small area for this example. The area fir this tutorial is a small courtyard:

Soundsensitive first.jpg

Now we need something for the microphone to detect from. An info_target is what we can used. Call this microphone1. In your map, it can be called anything you like. Now onto the actual entity setup. 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_microphone wont do it's sound checks correctly.
  • Sensitivity : 2 This should allow you not to be detected by crouching, but will detect you when you run or shoot.
  • Maximum hearing range : 512 This is the distance in units the env_microphone will hear.
  • Spawnflags :
  • Hears combat sounds
  • Hears world sounds
  • Hears player sounds
  • Hears bullet impacts
  • Hears explosions


Soundsensitive second.jpg


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_compare will 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 env_microphone.


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:

Object outputs: speaker - env_microphone
My Output Target Entity Target Input Parameter Delay Only Once
Io11.png SoundLevel spvol SetValueCompare <none> 0.00 No


Soundsensitive third.jpg


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 my case I have rigged up an alarm.

Output :

  • 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.

This is the final product:

File:Soundsensitive fourth.jpg

Example map

Hope this can be used in some very effective way, and have fun implementing it!