A SoundEffectInstance is a sound effect which provides a number of properties which can be used to modify how the sound is played back – for example volume, pitch, and whether the sound is looping.
How to create a SoundEffectInstance
To add a SoundEffectInstance to your project:
- Make sure you have a Glue project with a Screen or Entity which will contain the SoundEffectInstance.
- Add a new WAV file to your Screen or Entity. For more information, the .WAV file page.
- Once the file has been added to Glue, you need to change the RuntimeType to SoundEffectInstance:
At this point the SoundEffectInstance will be available in code, but you cannot change any variables on the SoundEffectInstance. To do this:
- Right-click on Objects
- Select “Add Object”
- Select the “From File” option
- Select the .wav file you added as a file
- Click OK
- Select the newly-created object
- Change “SourceName” to “Entire File (SoundEffectInstance)”
After setting up the object, you can modify the variables of the object in Glue. To do so, select the object and scroll to the “Unset Variables” category.
These variables can also be set through code:
// 50% volume:
SoundEffectInstanceObject.Volume = .5f;
// Pan it full left:
SoundEffectInstanceObject.Pan = -1.0f;