Aego Русский

Zones

While the listener is inside the Area of an Audio Zone 2D, the zone's Bus is turned to its Gain over Fade Time. The area is a rectangle in the zone node's space.

audio.WorldBusGain(bus) reports the last world-layer target selected by zones. The actual mixer also applies fade, session volume and player settings.

In Try it, the music bus drops to a fifth while the listening ball rolls through the purple area, and comes back when it leaves. Set Gain to 0 to silence the music inside, or raise Fade Time for a slower change.

Try it

Change the example parameters and compare the result. Reset restores the initial scene.

Starts the scene; open the example parameters to experiment.
Open in AegoDownload example project
Scene5 nodes
Ground
Transform
position[0, 2]rotation0scale[1, 1]
Sprite Renderer
spriteTextureasset("ae900000000000000000000000000010")layerint0orderint0tintColor#4b5563fforiginVec2[0.5, 0.5]sizeVec2[30, 0.6]flipXboolfalseflipYboolfalseblendenumpremultipliedfilterenumnearest
Rigid Body 2D
typeenumstaticmassModeenumautomassfloat0gravityScalefloat1linearDampingfloat0angularDampingfloat0fixedRotationboolfalsebulletboolfalseallowSleepbooltrueinterpolateboolfalselayerlayer0masklayer mask-1
Box Collider 2D
offsetVec2[0, 0]isTriggerboolfalsefrictionfloat0.2restitutionfloat0densityfloat1sizeVec2[30, 0.6]
Music
Transform
position[0, 0]rotation0scale[1, 1]
Audio Source 2D
clipClipasset("ae900000000000000000000000000a04")eventAssetRef<data>asset("00000000000000000000000000000000")volumefloat0.8pitchfloat1panfloat0busenummusicloopbooltrueplayOnStartbooltruespatialboolfalseminDistancefloat1maxDistancefloat10rolloffCurve{ ease=outQuad }panWidthfloat0.8pauseWithenumnever
Zone
Transform
position[0, -1]rotation0scale[1, 1]
Sprite Renderer
spriteTextureasset("ae900000000000000000000000000010")layerint0orderint0tintColor#7c3aed55originVec2[0.5, 0.5]sizeVec2[6, 8]flipXboolfalseflipYboolfalseblendenumpremultipliedfilterenumnearest
Audio Zone 2D
areaRect[-3, -4, 6, 8]busenummusicgainfloat0.2priorityint0fadeTimefloat0.4
Ball
Transform
position[-8, 1.2]rotation0scale[1, 1]
Sprite Renderer
spriteTextureasset("ae900000000000000000000000000010")layerint0orderint1tintColor#f59e0bfforiginVec2[0.5, 0.5]sizeVec2[1, 1]flipXboolfalseflipYboolfalseblendenumpremultipliedfilterenumnearest
Rigid Body 2D
typeenumdynamicmassModeenumautomassfloat0gravityScalefloat1linearDampingfloat0angularDampingfloat0fixedRotationbooltruebulletboolfalseallowSleepboolfalseinterpolatebooltruelayerlayer0masklayer mask-1
Circle Collider 2D
offsetVec2[0, 0]isTriggerboolfalsefrictionfloat0restitutionfloat0densityfloat1radiusfloat0.5
Camera
Transform
position[-8, 0]rotation0scale[1, 1]
Camera 2D
zoomfloat40viewportRect[0, 0, 1, 1]maskint-1orderint0clearbooltrueclearColorColor#111827ffscaleenumfitVirtualvirtualVec2[960, 540]activebooltrue
Virtual Camera 2D
priorityint0outputstring""zoomfloat0blendTimefloat0.6blendCurveCurve{ ease=inOutQuad }timeDomainenumunscaleduseBoundsboolfalseboundsRect[0, 0, 0, 0]snapToPixelsboolfalse
Camera Follow 2D
targetNodeRefnode("a0d40000000000000000000000000004")deadzoneRect[0.45, 0.4, 0.1, 0.2]dampingVec2[5, 5]lookaheadVec2[0, 0]maxLookaheadVec2[0, 0]lookaheadSmoothingfloat3snapDistancefloat20
Scriptmain.aes
package demo

// Walker rolls the listening ball through the zone and back; inside it the music bus drops to the zone's Gain.
script Walker {
    @export var Speed float = 5
    @export var Every float = 4

    var t float = 4
    var dir float = 1

    func Update(dt float) {
        t += dt
        if t < Every {
            return
        }
        t = 0
        body := node.Get<Body2D>()
        body.SetVelocity(Vec2{dir * Speed, 0})
        dir = -dir
    }
}