The Play
method in the Sandbox.Sound
class is a static method used to play a sound event specified by its name. It returns a SoundHandle
which can be used to control the playback of the sound.
The Play
method in the Sandbox.Sound
class is a static method used to play a sound event specified by its name. It returns a SoundHandle
which can be used to control the playback of the sound.
To use the Play
method, provide the name of the sound event you wish to play as a string. This method is useful for triggering sound effects or background music in your game.
// Example of playing a sound event string soundEventName = "explosion_sound"; SoundHandle handle = Sound.Play(soundEventName); // Use the handle to control the sound if needed handle.Stop(); // Stops the sound handle.SetVolume(0.5f); // Sets the volume to 50%