Course contentsShow
← Unity Game Development
Lesson 355 of 8285. UI and Audio SystemsFree lesson

Managing Audio Source Rolloff Curves

Customize logarithmic and linear attenuation curves to control how sound intensity dissipates over distance based on specific environmental acoustics.

In this lesson, you will learn how to fine-tune your Audio Source rolloff curves to create custom, realistic sound dissipation behavior based on the unique acoustics of your game world.

Understanding Rolloff Curves

By default, an Audio Source in 3D space uses a logarithmic rolloff, meaning the sound drops off quickly at first and then tapers off slowly. However, different environments require different behaviors. For instance, in a wide-open field, sound might dissipate linearly, while in a dense, sound-dampening forest, it might drop off much faster.

You can modify this behavior in the Inspector under the Audio Source component by setting the Volume Rolloff dropdown.

Customizing the Curve

When you select Custom Rolloff, the Distance graph appears. The X-axis represents distance (from 0 to Max Distance), and the Y-axis represents volume (0 to 1). By clicking the curve, you can add keyframes to create custom shapes:

  • Linear: A straight line from start to finish. Use this for predictable, mechanical distance fading.
  • Logarithmic: The standard "natural" feel, ideal for most ambient sounds.
  • Custom: This is your creative playground. You can create "shelves" where the volume stays loud for a while before dropping, or create a steep drop-off to simulate a physical barrier or a muffling effect.

Practical Implementation

You can also adjust these settings via script if you need to react to dynamic environmental changes, such as a player entering a "dead zone" where sound vanishes instantly:

AudioSource source = GetComponent<AudioSource>();
// Set the rolloff mode to Custom
source.rolloffMode = AudioRolloffMode.Custom;

// Access the curve and modify it
AnimationCurve customCurve = new AnimationCurve();
customCurve.AddKey(0f, 1f);     // At distance 0, volume is 100%
customCurve.AddKey(10f, 0f);    // At distance 10, volume is 0%
source.SetCustomCurve(AudioSourceCurveType.CustomRolloff, customCurve);

By manipulating these curves, you move beyond "default" audio and start crafting an acoustic signature that matches your game’s specific visual environment.

Key Takeaway: Custom Rolloff curves allow you to break away from linear assumptions, enabling you to hand-craft how sound loses intensity to match the physical properties of your game world.