S&box Wiki

Sound Events

Why Sound Events?

You just want to play a sound and are annoyed that you have to create a sound event to do it. Here's some of the things sound events can do for you.

  • Define whether sound is 2D or 3D
  • Define the volume
  • Randomly choose between multiple sounds each play
  • Randomly adjust volume or pitch each play
  • Can be fired from animations

Creating Sound Events In Code

You can define a sound event as a static field in any class in your addon. The class doesn't have to be an entity, it could be an empty class made especially to define sound events.

class ExampleClass { static SoundEvent ExampleSound = new ( "sounds/example.wav" ); }

This will create a sound event called ExampleClass.ExampleSound.

Using Sound Events

You can directly use the SoundEvent with Sound.Play.

TODO

Add reference to the managed audio system once added for further usage