Sound sensitive trigger: Difference between revisions

From Valve Developer Community
Jump to navigation Jump to search
No edit summary
No edit summary
Line 1: Line 1:
[[Category:Level Design]][[Category:Tutorials]]
[[Category:Level Design]][[Category:Tutorials]]
== Sound sensitive Trigger ==
= 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:
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:
Line 6: Line 6:
[[Image:Soundsensitive first.jpg]]
[[Image: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:
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.
'''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


'''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'''


[[Image:Soundsensitive second.jpg]]
[[Image: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.
Now we need a '''[[logic_compare]]''' to test the sound levels. We need the following parameters for it:


'''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.
'''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:


'''Output     : Target : Target input    : override : delay
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
|-
| [[Image:Io11.png]] || SoundLevel || spvol || SetValueCompare || <none> || 0.00 || No
|}


Soundlevel : spvol  : setvalue_compare :  none  : 0.00'''


[[Image:Soundsensitive third.jpg]]
[[Image: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.
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.


OnLessThan : this gets triggered when the sound level is under the trigger level.
'''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:
This is my final product :


[[Image:Soundsensitive fourth.jpg]]
[[Image:Soundsensitive fourth.jpg]]

Revision as of 16:09, 14 January 2006

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:


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 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)