core.audio_2d.create
Client
Creates a new audio-2d instance from a file path
Syntax
local instance = core.audio_2d.create(
path,
autoplay = false
)Parameters
| Type | Name | Description |
|---|---|---|
string | path | File path to the audio asset Refer Formats section |
bool | autoplay | Determines whether the audio starts playing immediately: • When true - playback begins as soon as the instance is created• When false - playback must be started manually via self:play() |
Returns
| Type | Name | Description |
|---|---|---|
audio_2d | instance | Created audio-2d instance |
Formats
| Format | Extension | Description |
|---|---|---|
| OGG | .ogg | Lossy compressed audio, ideal for music and ambience |
| WAV | .wav | Uncompressed audio, no lossy artifacts |
| MP3 | .mp3 | Lossy compressed audio, widely supported format |
Examples
local entity = core.audio_2d.create("sounds/ambient.ogg")
entity:play()local entity = core.audio_2d.create("sounds/ambient.ogg", true)
entity:set_volume(1.0)