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))
 
(8 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.


==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]] wont do it's sound checks correctly.
* '''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 to be detected by crouching, but will detect you when you run or shoot.
* '''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 21: 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:
[[Image:Soundsensitive second.jpg]]
 
 
Now we need a '''[[logic_compare]]''' to test the sound levels. We need the following parameters for it:
 


'''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 [[logic_compare]] will compare all values to, and can trigger an output depending on various states.
* '''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:


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:
{| 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
|-
|-
| [[Image:Io11.png]] || SoundLevel || spvol || SetValueCompare || <none> || 0.00 || No
| [[File:Io11.png]] || SoundLevel || spvol || SetValueCompare || <none> || 0.00 || No
|}
|}


[[File:Soundsensitive third.jpg|thumb|300px|right]]


[[Image: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 my case I have rigged up an alarm.


'''Output''' :
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.
* 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 :
'''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 fourth.jpg]]
Now you should have a working sound sensitive trigger!


[http://loz.snarkcafe.net/maps/HL2/soundsensitive_trigger.zip Example map]
==External links==


Hope this can be used in some very effective way, and have fun implementing it!
* [http://loz.snarkcafe.net/maps/HL2/soundsensitive_trigger.zip Example map]


--[[User:Dredfurst|Dredfurst]] 02:13, 30 Jun 2005 (PDT)
[[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.

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