TF2/Creating Audio Playing Buttons

From Valve Developer Community
< TF2
Revision as of 20:11, 20 December 2009 by Daedryon (talk | contribs) (Creating func_button)
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.
  • 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

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 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

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 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.
Note.png 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.