TF2/Creating Audio Playing Buttons
In this tutorial, you will learn how to add buttons into your map which you can use for playing sounds, music, or any music you want.
- Choose a 'Name'. For the tutorial, we'll call it "Button1"
- Set 'Speed' to whatever speed you want your button to move. Again, for the tutorial, we're gonna go with 5. If you don't want your button to move, click the 'Flags' tab, and check off the box beside Don't move.
- Choose a 'Sound'. This sound plays when your button is activated. This is completely optional.
- Just like the above step, choose a 'Locking Sound' and an 'Unlocking Sound'. Again, this is optional.
- Click the 'Flags' tab, and check off the box beside Damage Activates. If your button is low enough, you can check off Touch Activates as well. Also, if you want to have your button toggle the sound off when you shoot it a second time, check off the box beside Toggle
- Click the 'Output' tab, and enter the following:
- My output named: OnDamaged
- Targets entities name: SoundPlayer
- Via this input: PlaySound
Next, you need to create an ambient_generic entity.
- Choose a 'Name' for this entity. For the tutorial, we'll call it SoundPlayer.
- Choose a 'Sound Name'. For this, you have to click the "Browse" button and choose your sound.
- Set the 'Volume'. This variable controls how loud the sound will be played. We'll set it at 10.
- Set the 'Starting Volume'. This is optional. You can just leave it at it's default number.
- Set the 'Max Audible Distance'. This variable controls how far the sound can be heard from. There is no right or wrong number for this variable, it all depends on how far away you want players to hear the sound from.
- Set the 'Source Entity Name'. This variable is only used if you want to tie the entity in to a prop_dynamic/prop_static. If you want the sound to come from wherever you place the ambient_generic entity, don't change this. For the tutorial, we'll set it as Speaker1
- Click the 'Flags' tab. If you want your sound to be looped, uncheck the box next to Is NOT looped. If you want your sound to play once, make sure the box is checked off.
Optional: Setting Up Speakers
This is an optional step. If you chose a 'Source Entity Name' in the last step, this step will show you how to create the 'Source Entity Name'. Essentially, this step is only to be done if you want your sound to come out of prop, as opposed to coming from wherever you place the ambient_generic entity.
For the tutorial, we'll use a prop_dynamic entity, and for it's 'World Model', we'll use models/props_spytech/siren001.mdl.
- Set the 'Name' of the prop. For the tutorial, we'll use Speaker1. If you remember, in the last step, we set the 'Source Entity Name' of the ambient_generic to Speaker 1. This is where the speaker comes in.
And that's it! Your button is all set up, your sound is working. All you have to do is activate the button, and the sound will play.