Skip to content

Play Background Effect

Play Background Effect

Plays a looping or one-shot background sound effect that persists across scenes until stopped.

Properties

System

Name Explanation Type
Asset Name The audio asset file name when using variable mode. Variable or Value
Background Effect The background sound effect asset to play. Sound Effect
Fade In The fade-in duration in milliseconds when using variable mode. Variable or Value
Loop Length The loop length in milliseconds when using variable mode. Variable or Value
Loop Start The loop start position in milliseconds when using variable mode. Variable or Value
Looping Whether the background effect loops continuously when using variable mode. Switch or Value
Offset (milliseconds) The playback offset in milliseconds from which the background effect begins playing. Variable or Value
Pan The stereo panning value when using variable mode. Ranges from -1 (left) to 1 (right). Variable or Value
Pitch The pitch adjustment when using variable mode. Variable or Value
Result The variable to store the background effect's unique ID in. Variable or Value
Store ID Whether to store the unique ID of the background effect instance in a variable for later reference. Toggle
Use Variable When enabled, the background effect is constructed from variable values instead of a direct asset reference. Toggle
Volume The playback volume when using variable mode. Ranges from 0 (silent) to 1 (full volume). Variable or Value

Examples

Play a Background Effect by Asset Reference

Plays a looping background sound effect using a direct asset reference.

play_bgfx({name: "Content/Audio/Rain.ogg"});
{"Data":{"IsVariable":false,"StoreID":false,"Value":{"Name":"Content/Audio/Rain.ogg","Volume":1,"Pitch":0,"Pan":0,"IsPreventingMultiple":false},"Offset":{"IsGlobalVariable":false,"IsLocalVariable":false,"IsValue":true,"Value":"0","VariableIndex":0,"Metadata":null},"Result":{"IsGlobalVariable":true,"IsLocalVariable":false,"IsValue":false,"Value":"","VariableIndex":0,"Metadata":null},"SwitchIsLooping":{"IsGlobalSwitch":false,"IsLocalSwitch":false,"IsValue":true,"Value":false,"SwitchIndex":0},"VariableFadeIn":{"IsGlobalVariable":false,"IsLocalVariable":false,"IsValue":true,"Value":"0","VariableIndex":0,"Metadata":null},"VariableLoopLength":{"IsGlobalVariable":false,"IsLocalVariable":false,"IsValue":true,"Value":"","VariableIndex":0,"Metadata":null},"VariableLoopStart":{"IsGlobalVariable":false,"IsLocalVariable":false,"IsValue":true,"Value":"","VariableIndex":0,"Metadata":null},"VariableName":{"IsGlobalVariable":false,"IsLocalVariable":false,"IsValue":true,"Value":"","VariableIndex":0,"Metadata":null},"VariablePan":{"IsGlobalVariable":false,"IsLocalVariable":false,"IsValue":true,"Value":"0","VariableIndex":0,"Metadata":null},"VariablePitch":{"IsGlobalVariable":false,"IsLocalVariable":false,"IsValue":true,"Value":"0","VariableIndex":0,"Metadata":null},"VariableVolume":{"IsGlobalVariable":false,"IsLocalVariable":false,"IsValue":true,"Value":"1","VariableIndex":0,"Metadata":null},"Metadata":null},"TypeName":"MAR.Game.Shared.Models.Scripts.Commands.Audio.PlayBackgroundEffectCommand"}

Play a Background Effect and Store Its Unique ID

Plays a background sound effect and stores its unique ID in global variable 0 for later reference.

$gv[0] = play_bgfx({name: "Content/Audio/Rain.ogg"});
{"Data":{"IsVariable":false,"StoreID":true,"Value":{"Name":"Content/Audio/Rain.ogg","Volume":1,"Pitch":0,"Pan":0,"IsPreventingMultiple":false},"Offset":{"IsGlobalVariable":false,"IsLocalVariable":false,"IsValue":true,"Value":"0","VariableIndex":0,"Metadata":null},"Result":{"IsGlobalVariable":true,"IsLocalVariable":false,"IsValue":false,"Value":"","VariableIndex":0,"Metadata":null},"SwitchIsLooping":{"IsGlobalSwitch":false,"IsLocalSwitch":false,"IsValue":true,"Value":false,"SwitchIndex":0},"VariableFadeIn":{"IsGlobalVariable":false,"IsLocalVariable":false,"IsValue":true,"Value":"0","VariableIndex":0,"Metadata":null},"VariableLoopLength":{"IsGlobalVariable":false,"IsLocalVariable":false,"IsValue":true,"Value":"","VariableIndex":0,"Metadata":null},"VariableLoopStart":{"IsGlobalVariable":false,"IsLocalVariable":false,"IsValue":true,"Value":"","VariableIndex":0,"Metadata":null},"VariableName":{"IsGlobalVariable":false,"IsLocalVariable":false,"IsValue":true,"Value":"","VariableIndex":0,"Metadata":null},"VariablePan":{"IsGlobalVariable":false,"IsLocalVariable":false,"IsValue":true,"Value":"0","VariableIndex":0,"Metadata":null},"VariablePitch":{"IsGlobalVariable":false,"IsLocalVariable":false,"IsValue":true,"Value":"0","VariableIndex":0,"Metadata":null},"VariableVolume":{"IsGlobalVariable":false,"IsLocalVariable":false,"IsValue":true,"Value":"1","VariableIndex":0,"Metadata":null},"Metadata":null},"TypeName":"MAR.Game.Shared.Models.Scripts.Commands.Audio.PlayBackgroundEffectCommand"}

Play a Background Effect from Variables

Plays a background sound effect constructed from variable values with a fade-in and looping enabled.

play_bgfx(name: $gv[0], fade_in: 2000, is_looping: true);
{"Data":{"IsVariable":true,"StoreID":false,"Value":{"Name":"","Volume":1,"Pitch":0,"Pan":0,"IsPreventingMultiple":false},"Offset":{"IsGlobalVariable":false,"IsLocalVariable":false,"IsValue":true,"Value":"0","VariableIndex":0,"Metadata":null},"Result":{"IsGlobalVariable":true,"IsLocalVariable":false,"IsValue":false,"Value":"","VariableIndex":0,"Metadata":null},"SwitchIsLooping":{"IsGlobalSwitch":false,"IsLocalSwitch":false,"IsValue":true,"Value":true,"SwitchIndex":0},"VariableFadeIn":{"IsGlobalVariable":false,"IsLocalVariable":false,"IsValue":true,"Value":"2000","VariableIndex":0,"Metadata":null},"VariableLoopLength":{"IsGlobalVariable":false,"IsLocalVariable":false,"IsValue":true,"Value":"","VariableIndex":0,"Metadata":null},"VariableLoopStart":{"IsGlobalVariable":false,"IsLocalVariable":false,"IsValue":true,"Value":"","VariableIndex":0,"Metadata":null},"VariableName":{"IsGlobalVariable":true,"IsLocalVariable":false,"IsValue":false,"Value":"","VariableIndex":0,"Metadata":null},"VariablePan":{"IsGlobalVariable":false,"IsLocalVariable":false,"IsValue":true,"Value":"0","VariableIndex":0,"Metadata":null},"VariablePitch":{"IsGlobalVariable":false,"IsLocalVariable":false,"IsValue":true,"Value":"0","VariableIndex":0,"Metadata":null},"VariableVolume":{"IsGlobalVariable":false,"IsLocalVariable":false,"IsValue":true,"Value":"1","VariableIndex":0,"Metadata":null},"Metadata":null},"TypeName":"MAR.Game.Shared.Models.Scripts.Commands.Audio.PlayBackgroundEffectCommand"}