• Studio

  • Studio API

  • Bots

  • Web API

  • Designer Resources

  • Host Resources

  • Globals

    AudioShader

    Inherits from:

    Provides functionality for audio manipulation and playback, including volume and pitch adjustments, spatial considerations, and muting capabilities.

    Properties

    Collection of AudioClip to select from when playing.

    pitch

    number
    ClientOnly

    Pitch will make audio sound higher or lower. The default value is 1, representing no change to the pitch. Lower values result in lower sounds, while higher values produce higher sounds. Valid values are from .01 to 2.

    -- Set the pitch of the audio
    audioShaderInstance.pitch = 1.2
    

    randomPitch

    number
    ClientOnly

    A range from which a random value will be selected and applied to the pitch when playing. A value between [-randomPitch, randomPitch] will be added to the pitch when playing. The default value is 0, meaning no change to the pitch. Valid values are between 0 and 1.

    -- Set the random pitch range of the audio
    audioShaderInstance.randomPitch = 0.2
    

    randomVolume

    number
    ClientOnly

    A range of random values to apply to the volume when playing. Will add [-randomVolume, randomVolume] to the volume.

    -- Set the random volume range of the audio
    audioShaderInstance.randomVolume = 0.1
    

    volume

    number
    ClientOnly

    The volume that the audio source will play. This is a normalized value (valid range is from 0 to 1).

    -- Set the volume of the audio
    audioShaderInstance.volume = 0.5
    

    isMuted

    boolean
    ClientOnly

    Determines whether the audio is currently muted.

    spatialRange

    number
    ClientOnly
    ReadOnly

    Maximum range at which the clip can be heard

    -- Set the spatial range of the audio
    audioShaderInstance.spatialRange = 10
    

    Methods

    GetRandomClip

    ClientOnly

    Get a random clip from the array of AudioClip. If there is only one AudioClip assigned, that clip will always be returned.

    -- Get a random AudioClip
    local randomClip = audioShaderInstance:GetRandomClip()
    

    Returns

    The randomly selected AudioClip object.

    Play

    ClientOnly

    Play a random AudioClip from the clips array. Use PlayWithVolume or PlayWithVolumeAndPitch to specify volume and pitch.

    -- Play a random AudioClip
    audioShaderInstance:Play()
    

    Returns

    void

    PlayWithVolume

    ClientOnly

    Play a random AudioClip from the clips array with a volume.

    Parameters

    v
    number

    Returns

    void

    Play a random AudioClip from the clips array, optionally specifying a volume and pitch. If volume and pitch are not provided, a default value of 1 is used for each.

    Parameters

    volume
    number

    The volume the clip will play. Note that this value may be affected by the AudioMixer in use.

    pitch
    number

    The pitch the clip will play.

    Returns

    void

    new

    ClientOnly

    Create a new default audio shader from a UnityEngine.AudioClip. AudioShaders are used to play sound effects or music. They can contain any number of AudioClip in the 'clips' array. If there is more than one AudioClip, a random entry is selected each time the AudioShader is played.

    Parameters

    The AudioClip to associate with the new AudioShader instance.

    Returns

    A new instance of AudioShader configured with the provided AudioClip.

    Updated 17 days ago

    PocketWorlds Icon

    © 2025 Pocket Worlds. All rights reserved.