TruWorlds

Audio

Inherits: Instance

Audio is a DynamicInstance that can play either sound effect or music tracks

Properties

AudioAsset AssetId
AudioId string
AutoStart bool

If true, the audio will immediately begin playing when it is added to the world.

IsPlaying bool

Whether the audio is currently playing. This is read-only and can only be changed by calling Play() or Stop().

Loop bool

If true, the audio will loop indefinitely until stopped. If false, the audio will play once and then stop.

MaxDistance float

The maximum distance at which the audio can be heard. By default, audio uses linear attenuation to determine volume over distance.

OneShot bool

If true, the audio will call Destroy() on itself after it finishes playing. This takes priority over Loop, so if both Loop and OneShot are true, the audio will play once and then be removed.

Pitch float

The pitch of the audio, where 1 is normal pitch, less than 1 is lower pitch, and greater than 1 is higher pitch. Default is 1.

TimeLength float

The total length of the audio, in seconds.

TypeHint AudioTypeHint
Volume float

The volume of the audio, from 0 (silent) to 1 (full volume). Default is 1.

Functions

Play()

Plays the audio from the beginning. If the audio is already playing, this does nothing.

Stop()

Stops the audio if it is currently playing. If the audio is not playing, this does nothing.