Sound Effect
Audio emitter for one-shot and recurring sound effects (.wav, .ogg) with volume and pitch control.
Type: SoundNode · Category: Audio & Sound · Also found as: sound
Properties
Section titled “Properties”| Property | Type | Default | Description |
|---|---|---|---|
volume |
number | 1 |
Volume (0-1), before the bus and master volumes. Range 0 to 1. |
pitch |
number | 1 |
Playback speed / pitch (1 = normal). Range 0.1 to 3. |
bus |
string | "" |
The mixer bus it plays into (the Mixer tab; empty = SFX): its fader, effects and output apply. |
caption |
string | "" |
Shown on the subtitle track when it plays, for players with sound captions on (e.g. “[door creaks]”). |
autoplay |
boolean | false |
Play once when the node becomes ready. |
voices |
integer | 1 |
Plays over itself up to this many times (1: a new play restarts it). Range 1 to 8. |
positional |
boolean | false |
Volume and pan follow the node’s distance and side from the listener (the current camera). |
minDistance |
number | 100 |
Positional: full volume within this distance (px). Range 0 to 4000. |
maxDistance |
number | 900 |
Positional: silent beyond this distance (px). Range 1 to 8000. |
Plus the common properties every node has.
Lua methods
Section titled “Lua methods”Call them on the node (self.node in its script, or self.node:get_node("path")). Every node also has the Node methods.
SoundNode:connect(event, handler)
Section titled “SoundNode:connect(event, handler)”Connects a handler to one of this node’s events: finished (Playback (or the dialogue) ended); the tree events; custom ones.
self.node:connect("finished", function(value, source) Log.info("finished") end)eventSoundNodeEvent|stringhandlerfun(value:any, source: SoundNode)
Returns integer id Connection id for disconnect
SoundNode:get_property(path)
Section titled “SoundNode:get_property(path)”Reads an Inspector property by its path (vectors and colours as tables); “script.
local value = self.node:get_property("volume")pathSoundNodeProperty|string
Returns any
SoundNode:set_property(path, value, y)
Section titled “SoundNode:set_property(path, value, y)”Sets an Inspector property by its path: vectors as {x, y} or x, y; colours as {r, g, b[, a]} 0..1 or “#rrggbb[aa]”; enums by name; “script.
self.node:set_property("volume", 1.5)pathSoundNodeProperty|stringvalueanyy?number
SoundNode:sound_play()
Section titled “SoundNode:sound_play()”Plays the sound effect associated with this SoundNode.
self.node:get_node("JumpSound"):sound_play()SoundNode:sound_stop()
Section titled “SoundNode:sound_stop()”Stops playing the sound effect.
self.node:get_node("EngineSound"):sound_stop()SoundNode:sound_pause()
Section titled “SoundNode:sound_pause()”Pauses the sound effect.
self.node:get_node("EngineSound"):sound_pause()SoundNode:sound_resume()
Section titled “SoundNode:sound_resume()”Resumes the paused sound effect.
self.node:get_node("EngineSound"):sound_resume()In a scene file
Section titled “In a scene file”{ "type": "SoundNode", "name": "SoundEffect", "position": [ 0, 0 ], "properties": { "volume": 1, "pitch": 1, "bus": "" }}