Sound In Code

From Valve Developer Community
Revision as of 10:30, 21 January 2011 by Beerdude26 (talk | contribs) (Created page.)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Emit sound from entity

Use EmitSound to emit a sound from a base entity:

EmitSound( "soundscript.file" );

See the CSoundEmitterSystem class in SoundEmitterSystem.cpp for overloads and implementation details.

Play sounds anywhere

To play a sound on the client, use the following code:

enginesound->EmitAmbientSound( "link/to/soundfile", 1.0f );

You may need to include #include "engine/ienginesound.h" in order to get access to the interface. [[Category::Programming]]