Skip to reading
GDScript Programming & Godot

Gameplay: Audio, video, FMV and recorded gameplay

Edition 0.86.4.1 HF1

0.86.4.1 Hotfix 1 edition. Earlier lessons and screenshots retain their original version context; revised references and supplements describe the newer behavior.

Download PDFView PDF page
On this page

Sound effects, music, voice and video use separate playback routes. A sound channel gives you a handle for stopping, pausing or fading a group of effects. Starting playback usually lets the next instruction run immediately.

PlaySound()#

Play Sound

Start an imported audio asset as a sound effect, optionally on a named channel.

Source table from Gameplay: Audio, video, FMV and recorded gameplay, page 198
Option key / fieldMeaning and inputDefault
Sound Asset assetIdChoose an imported audio asset.Blank
Channel / ID channelSound-effect channel name. Reuse it to pause, stop or fade that sound group.Blank

Timing. Waits for the runtime routine to return; no further completion wait is promised by this schema.

Code example
await PlaySound({"assetId": "chime", "channel": "puzzle"})

In use. Play chime on puzzle, then continue the list. Use that same channel to stop or fade the effect later. A blank channel has broader/default behavior; name important continuing sounds.

StopSound()#

Stop Sound

Stop effects selected by channel.

Source table from Gameplay: Audio, video, FMV and recorded gameplay, page 198
Option key / fieldMeaning and inputDefault
Channel / ID channelSound-effect channel name. Reuse it to pause, stop or fade that sound group.Blank

Timing. Waits for the runtime routine to return; no further completion wait is promised by this schema.

Code example
await StopSound({"channel": "puzzle"})

In use. Stop the machine channel when the power is cut. Use a specific channel so unrelated effects can continue. This does not stop music or voice.

Page 198 of 378Permalink
Go to page