TF2/Creating Audio Playing Buttons

From Valve Developer Community
< TF2
Jump to: navigation, search
한국어

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.

Creating func_button

The func_button entity

To start, you'll need to create a world brush, and tie it into a func_button entity (CTRL+T).

  • Choose a 'Name'. For the tutorial, we'll call it "Button 1"
  • 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.
  • If you want your button to move, you can change the direction it moves in by editing 'Move direction'. Simply change the Pitch, Yaw and Roll.
  • Choose a 'Sound'. This sound plays when your button is activated. This is completely optional.
  • Set the 'Delay before reset' to -1. This ensures that once your sound effect or music is finished, shooting the button will allow you to play it again.
  • 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.
  • Click the 'Output' tab, and enter the following:
My output named: OnDamaged
Targets entities name: SoundPlayer
Via this input: PlaySound

Creating ambient_generic

The ambient_generic entity

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 Speaker 1
  • 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

The 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 a 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 Speaker 1. 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.
Note:Remember, you don't have to use a siren model, you can make the sound come from whatever you want.

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.

Tips

  • You can make the button play sound out of more than one source. Simply create as many ambient_generic entities as you need, name them all, for example "SoundPlayer1", "SoundPlayer2". Then bring up the 'Output' tab of the func_button, and add more outputs, 1 for every new ambient_generic, and the following into the output:
My output named: OnDamaged
Targets entities name: <Name of your ambient_generic entity, for example SoundPlayer1, Soundplayer 2, etc>
Via this input: PlaySound
Once you shoot the button the sound will play through all the speakers.