Description
The Sounds
property of the SoundEvent
class is a list of SoundFile
objects. When a sound event is triggered, a random sound from this list will be selected and played. This allows for variability in sound playback, enhancing the auditory experience by providing different sounds for the same event.
Usage
To use the Sounds
property, you need to add SoundFile
objects to the list. These sound files will be the candidates for random selection when the sound event is triggered. Ensure that the list is populated with valid sound files before triggering the event to avoid errors.
Example
// Example of setting up a SoundEvent with multiple sounds
SoundEvent mySoundEvent = new SoundEvent();
// Add sound files to the Sounds list
mySoundEvent.Sounds.Add(new SoundFile("sound1.wav"));
mySoundEvent.Sounds.Add(new SoundFile("sound2.wav"));
mySoundEvent.Sounds.Add(new SoundFile("sound3.wav"));
// When the sound event is triggered, one of the sounds will be played
mySoundEvent.Trigger();