Sound sensitive trigger: Difference between revisions
m (→Making the trigger: removed space) |
Thunder4ik (talk | contribs) m (Unicodifying, replaced: External Links → External links, [[Image: → [[File: (4)) |
||
(One intermediate revision by one other user 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. | 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== | ==Getting started== | ||
Line 11: | Line 11: | ||
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. | 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: | Then, create an <code>[[env_microphone]]</code>. This is the entity that will control the sound output level. Give it the following properties: | ||
Line 36: | Line 36: | ||
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: | 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== | ==Making the trigger== | ||
Line 55: | Line 55: | ||
Now you should have a working sound sensitive trigger! | Now you should have a working sound sensitive trigger! | ||
==External | ==External links== | ||
* [http://loz.snarkcafe.net/maps/HL2/soundsensitive_trigger.zip Example map] | * [http://loz.snarkcafe.net/maps/HL2/soundsensitive_trigger.zip Example map] |
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!