RB.SoundPlay
Method - Static
Parameters
audio
|
AudioAsset
|
Audio Asset to play
|
volume
|
float
|
Volume to play at where 0 is silent, 1 is the original clip volume, and values greater than 1 indicate amplification beyond the recorded volume. Defaults to 1
|
pitch
|
float
|
Pitch to play at, where 1 is the original sound pitch, values less than 1 indicate lower pitch, and values greater than 1 indicate higher pitch. Defaults to 1
|
priority
|
int
|
Priority level of the sound. If there are no more sound channels left then the lowest priority sound below this priority will be stopped, and replace by this sound.
|
Returns
SoundReference
Sound reference
DescriptionPlay the sound from the given AudioAsset. This function returns the SoundReference of the playing sound, which can then be used to adjust the playback of the sound, stop the sound, or check its state. Optionally the initial volume and pitch can also be specified. Note that RB.SoundPlay can be called on the same SoundAsset multiple times, and the playing sound clip can overlap itself. Each instance of the playing sound will have its own independent SoundReference returned. ExampleAudioAsset soundExplosion = new AudioAsset();
void Initialize() { soundExplosion.Load("sounds/explosion"); }
void Update() { if (dead) { float volume = 0.5f; float pitch = Random.Range(0.9f, 1.1f); RB.SoundPlay(soundExplosion, volume, pitch); } } |
See AlsoAudioAsset RB.SoundStop RB.SoundIsPlaying RB.SoundVolumeSet RB.SoundPitchSet RB.SoundVolumeGet RB.SoundPitchGet RB.SoundLoopSetSee DocsFeatures - Sound |