Skip to content

CVR Audio Driver

Switches between multiple audio clips that share a single AudioSource. Useful when you need many audio clips at the same location with the same settings.

The Audio Source the clips play on. The component assigns the selected clip onto audioSource.clip before playback.

List of Audio Clips to switch between.

Index into audioClips for the currently selected clip. Can be driven at runtime by an animation: the component watches for changes in OnValidate and OnDidApplyAnimationProperties and swaps the clip when the value changes.

If enabled, the new clip plays automatically when the selection changes. Default true.

All methods are exposed to Lua scripting under the CVR.CCK module.

MethodDescription
PlaySound(int index)Sets selectedAudioClip to index, and if playOnSwitch is true, plays the clip.
PlaySound()Plays the currently assigned clip on the AudioSource if it is active and enabled.
PlayNext()Advances to the next clip in the list (wraps to 0).
PlayPrev()Moves to the previous clip in the list (wraps to the last entry).
SelectRandomSound()Picks and plays a random clip from the list.
SetAudioClip(int index)Sets the selected clip without playing. Returns false if the index is out of bounds or the clip or source is null.

The component also exposes AnimEventPlaySound, AnimEventPlayNext, AnimEventPlayPrev, and AnimEventSelectRandomSound for use as Unity AnimationEvent targets.

  • CVR-GameFiles/ABI.CCK.Components/CVRAudioDriver.cs