Sound In Code: Difference between revisions
Jump to navigation
Jump to search
Androidtv12 (talk | contribs) No edit summary |
Androidtv12 (talk | contribs) No edit summary |
||
Line 1: | Line 1: | ||
{{otherlang2|ru=:Sound In Code:ru}} | |||
== Emit sound from entity == | == Emit sound from entity == | ||
Use <code>EmitSound</code> to emit a sound from a base entity: | Use <code>EmitSound</code> to emit a sound from a base entity: |
Revision as of 09:20, 16 July 2018
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.
Play sounds via VGUI interface
#include "vgui/ISurface.h"
using namespace vgui;
vgui::surface()->PlaySound( "common/talk.wav" ); // Starts from the 'sound' folder