Sound sensitive trigger

From Valve Developer Community
Revision as of 02:20, 30 June 2005 by Dredfurst (talk | contribs)
Jump to navigation Jump to search

Sound sensitive Trigger

In this tutorial, I will explain how we make a trigger that will detect and trigger depending on the sound levels in the surrounding area. Right, lets get stuck in. First of all, make yourself a small area for this example. I’ve made myself a small courtyard:

Soundsensitive first.jpg

Now I need something for the microphone to detect from. an info_target is what I 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:

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:

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:

Output  : Target : Target input  : override : delay

Soundlevel : spvol  : setvalue_compare : none  : 0.00

Soundsensitive third.jpg

The final step now is to set up the output of the logic compare to trigger something. this can eb 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 my final product:

File:Soundsensitive fourth.jpg

Example map

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

--Dredfurst 02:13, 30 Jun 2005 (PDT)