Sound sensitive trigger: Difference between revisions
Hurricaaane (talk | contribs) mNo edit summary |
Thunder4ik (talk | contribs) m (Unicodifying, replaced: External Links → External links, [[Image: → [[File: (4)) |
||
(7 intermediate revisions by 3 users not shown) | |||
Line 1: | Line 1: | ||
This tutorial will explain the process of making a trigger that will detect sound levels in the surrounding area and go off. | |||
[[File:Soundsensitive first.jpg|thumb|300px|right]] | |||
==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 <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. | |||
[[File:Soundsensitive second.jpg|thumb|300px|right]] | |||
Then, create an <code>[[env_microphone]]</code>. This is the entity that will control the sound output level. Give it the following properties: | |||
'''Classname''' : env_microphone | '''Classname''' : env_microphone | ||
* '''Name : speaker''' In your map again, this can be anything at all. | * '''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]] | * '''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 not | * '''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. | * '''Maximum hearing range : 512''' This is the distance in units the <code>[[env_microphone]]</code> will hear. | ||
* '''Spawnflags :''' | * '''Spawnflags :''' | ||
:* Hears combat sounds | :* Hears combat sounds | ||
Line 20: | Line 27: | ||
:* Hears explosions | :* Hears explosions | ||
Now we need a <code>[[logic_compare]]</code> to test the sound levels. We need the following parameters for it: | |||
Now we need a | |||
'''Classname''' : logic_compare | '''Classname''' : logic_compare | ||
* '''Name : spvol''' Our entity's name again, this entity checks the volume of the microphone and can trigger things. | * '''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 | * '''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 env_microphone. | * '''Compare value : 0.5''' This is the trigger level to trigger things from the sound level of the <code>env_microphone</code>. | ||
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: | |||
{| class=standard-table | |||
{| | |||
|+Object outputs: speaker - env_microphone | |+Object outputs: speaker - env_microphone | ||
! || My Output || Target Entity || Target Input || Parameter || Delay || Only Once | ! || My Output || Target Entity || Target Input || Parameter || Delay || Only Once | ||
|- | |- | ||
| [[ | | [[File:Io11.png]] || SoundLevel || spvol || SetValueCompare || <none> || 0.00 || No | ||
|} | |} | ||
[[File:Soundsensitive third.jpg|thumb|300px|right]] | |||
==Making the trigger== | |||
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. | |||
This is | '''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== | |||
* [http://loz.snarkcafe.net/maps/HL2/soundsensitive_trigger.zip Example map] | |||
[[Category:Level Design]] | |||
[[Category:Tutorials]] |
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.
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.
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 theenv_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:
My Output | Target Entity | Target Input | Parameter | Delay | Only Once | |
---|---|---|---|---|---|---|
![]() |
SoundLevel | spvol | SetValueCompare | <none> | 0.00 | No |
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!