AudioSource
A sound on a node: autoplay it as an ambient loop, or fire it from an animation trigger with several takes to vary it. Positional quiets and pans it by distance. A looping autoplay on the Music bus is the room's one music track instead.
On this page
Add it
+ Add node → Audio Source creates a node with it already on. Already have a node for it? Add component → AudioSourceComponent.
From a script
A script on the same node writes these fields by name. AudioSourceComponent is the name to pass.
rgs
set_number("AudioSourceComponent", "volume", 1.0);
set_number("AudioSourceComponent", "pitch", 1.0);
set_flag("AudioSourceComponent", "looping", false);
set_flag("AudioSourceComponent", "autoplay", false);
set_flag("AudioSourceComponent", "positional", true);
set_number("AudioSourceComponent", "max_distance", 512.0);
set_number("AudioSourceComponent", "blend", 1.0);
set_number("AudioSourceComponent", "min_distance", 0.0);
set_number("AudioSourceComponent", "pan", 0.0); Fields
| Field | Script name | Kind | Default | What it does | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Clip | clip | asset | none | The clip Autoplay plays. Each trigger plays the clips on its own row. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Bus | bus | one of Master, Music, Sfx | Sfx | Which bus it routes through. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Volume | volume | number, 0 to 1, step 0.01 | 1 | The source's own volume, before bus and distance. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Pitch | pitch | number, 0.01 to 4, step 0.01 | 1 | Playback rate. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Looping | looping | checkbox | off | Repeat the Clip Autoplay starts until it is stopped. A trigger played by play_sound or an animation track plays once; one played by play_music loops. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Autoplay | autoplay | checkbox | off | Start playing as soon as the node exists. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Spatial | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Positional | positional | checkbox | on | Make it quieter, and pan it, by its distance from the listener, or the camera when the scene has no Audio Listener. A looping autoplay on the Music bus is the music track, and is never positional. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Max Distance | max_distance | number, at least 0 | 512 | Distance at which it can no longer be heard. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Blend | blend | number, 0 to 1, step 0.01 | 1 | 0 is 2D, 1 is positional. Shown when Positional is set | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Rolloff | rolloff | one of Quadratic, Linear, Inverse, Logarithmic, Custom | Quadratic | The shape of the falloff out to Max Distance. Shown when Positional is set | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Min Distance | min_distance | number, at least 0 | 0 | Distance out to which it stays at full volume. Shown when Positional is set | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Pan | pan | number, -1 to 1, step 0.01 | 0 | Stereo placement, added to whatever the listener gives it. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Max Voices | max_voices | number, 0 to 32, step 1 | 0 | Most voices this node holds at once. 0 is the global cap only. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Triggers | triggers | list | empty | Animation trigger names, and the clip each one fires. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||