Sound sensitive trigger: Difference between revisions

From Valve Developer Community
Jump to navigation Jump to search
No edit summary
m (Unicodifying, replaced: External Links → External links, [[Image: → [[File: (4))
 
(9 intermediate revisions by 4 users not shown)
Line 1: Line 1:
[[Category:Level Design]][[Category:Tutorials]]
This tutorial will explain the process of making a trigger that will detect sound levels in the surrounding area and go off.
== 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:
[[File:Soundsensitive first.jpg|thumb|300px|right]]


[[Image:Soundsensitive first.jpg]]
==Getting started==


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


'''name : speaker''' in your map again, this can be anything at all.
==Setting up the necessary entities==


'''Measure Target : microphone1''' make sure this is the name of your info_target, otherwise the env_microphone wont do it's sound checks correctly.
We need something for the ''microphone'' to detect from. An <code>[[info_target]]</code> is what we will be using. Call it <code>microphone1</code>. In your map, it can be called anything you like.  


'''Sensitivity : 2''' this should allow you not to be detected by crouching, but will detect you when you run or shoot
[[File:Soundsensitive second.jpg|thumb|300px|right]]


'''Maximum hearing range : 512''' This is the distance in units the env_microphone will hear
Then, create an <code>[[env_microphone]]</code>. This is the entity that will control the sound output level. Give it the following properties:


'''Spawnflags : Hears combat sounds, Hears world sounds, Hears player sounds, hears bullet impacts, hears explosions'''
'''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 <code>[[info_target]]</code>, otherwise the <code>[[env_microphone]]</code> won'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 <code>[[env_microphone]]</code> will hear.
* '''Spawnflags :'''
:* Hears combat sounds
:* Hears world sounds
:* Hears player sounds
:* Hears bullet impacts
:* Hears explosions


[[Image:Soundsensitive second.jpg]]
Now we need a <code>[[logic_compare]]</code> to test the sound levels. We need the following parameters for it:


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 <code>logic_compare</code> 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 <code>env_microphone</code>.


'''name : spvol''' Our entity's name again, this entity checks the volume of the microphone and can trigger things.
Now we need to set up some of the entity I/O on our <code>env_microphone</code>. Add a new output to our <code>env_microphone</code> with the following options:


'''initial value : 0''' this is what the logic_compare will compare all values to, and can trigger an output depending on various states.
{| class=standard-table
|+Object outputs: speaker - env_microphone
!  || My Output || Target Entity || Target Input || Parameter || Delay || Only Once
|-
| [[File:Io11.png]] || SoundLevel || spvol || SetValueCompare || <none> || 0.00 || No
|}


'''compare value : 0.5''' this is the trigger level to trigger things from the sound level of the env_microphone.
[[File:Soundsensitive third.jpg|thumb|300px|right]]


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:
==Making the trigger==


'''Output    : Target : Target input     : override : delay
The final step now is to set up the output of the <code>logic_compare</code> 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.


Soundlevel : spvol  : setvalue_compare :   none  : 0.00'''
'''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.


[[Image:Soundsensitive third.jpg]]
Now you should have a working sound sensitive trigger!


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.
==External links==


Output :  
* [http://loz.snarkcafe.net/maps/HL2/soundsensitive_trigger.zip Example map]


OnGreaterThan : this gets triggered when the sound level is past the trigger level.
[[Category:Level Design]]
 
[[Category:Tutorials]]
OnLessThan : this gets triggered when the sound level is under the trigger level.
 
this is my final product:
 
[[Image:Soundsensitive fourth.jpg]]
 
[http://loz.snarkcafe.net/maps/HL2/soundsensitive_trigger.zip Example map]
 
Hope this can be used in some very effective way, and have fun implementing it!
 
--[[User:Dredfurst|Dredfurst]] 02:13, 30 Jun 2005 (PDT)

Latest revision as of 00:08, 7 January 2024

This tutorial will explain the process of making a trigger that will detect sound levels in the surrounding area and go off.

Soundsensitive first.jpg

Getting started

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.

Soundsensitive second.jpg

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_microphone won'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 env_microphone will hear.
  • 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_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

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.

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.

Now you should have a working sound sensitive trigger!

External links