AudioAsset
Ease
FastString
FontAsset
NineSlice
PackedSprite
PackedSpriteID
RB
   HardwareSettings
   IRetroBlitGame
RBAsset
Rect2i
ShaderAsset
SoundReference
SpriteGrid
SpriteSheetAsset
TMXMapAsset
   TMXLayer
   TMXLayerLoadState
   TMXObject
   TMXObjectGroup
   TMXProperties
Vector2i

RB.SoundPlay

Method  -  Static

public static SoundReference SoundPlay(AudioAsset audio, float volume = 1.0f, float pitch = 1.0f, int priority = 0)

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

Description

Play 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.

Example

AudioAsset soundExplosion = new AudioAsset();

void Initialize() {
    soundExplosion.Load("sounds/explosion");
}

void Update()
{
    if (dead) {
        float volume = 0.5f;
        float pitch = Random.Range(0.9f1.1f);
        RB.SoundPlay(soundExplosion, volume, pitch);
    }
}

See Also

AudioAsset
RB.SoundStop
RB.SoundIsPlaying
RB.SoundVolumeSet
RB.SoundPitchSet
RB.SoundVolumeGet
RB.SoundPitchGet
RB.SoundLoopSet

See Docs

Features - Sound