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

Defining Audio Rolloff Curves for Realistic Environments

Learners will customize logarithmic and linear rolloff curves to control how sound volume diminishes as objects move away from the listener.

In this lesson, you will learn how to customize volume attenuation curves in Unity to simulate how different sounds fade out over distance.

When you work with 3D audio, the Audio Source component automatically handles volume changes based on how far an object is from the Audio Listener. By default, Unity uses a standard falloff, but in a realistic environment, not every sound behaves the same way. A whisper might fade quickly, while an explosion or a thunderclap might remain audible over a much longer distance.

Understanding Rolloff Curves

The Rolloff Mode setting in the Audio Source Inspector dictates how the volume curve is calculated. You can access this by selecting your Audio Source and navigating to the 3D Sound Settings foldout.

  • Linear Rolloff: The volume decreases at a constant rate as distance increases. This is simple and predictable, but it often sounds unnatural because real-world sounds usually drop off sharply at first and then linger at lower volumes.
  • Logarithmic Rolloff: This mimics real-world acoustics. The volume drops rapidly close to the source and tapers off slowly as the distance grows. This is the gold standard for realistic environments.
  • Custom Rolloff: This allows you to manually draw the curve. You can click on the graph in the Inspector to add keyframes, letting you create unique behaviors—for example, making a sound maintain full volume for a specific distance before dropping off instantly.

Practical Implementation

To customize your rolloff, set the Volume Rolloff dropdown to Custom. You will see a graph appear:

  1. Horizontal Axis (X): Represents the distance from the Audio Listener.
  2. Vertical Axis (Y): Represents the volume (0 to 1).

By dragging the handles on this line, you control the "falloff envelope." For a subtle effect, ensure the curve starts at 1.0 (full volume) and gradually descends to 0.0 at your Max Distance. If you want a sound to be "loud" even when relatively far away, keep the curve high for a longer stretch of the horizontal axis before letting it slope down.

Key Takeaway: By switching from default settings to a Custom Rolloff curve, you gain precise control over your soundscape, allowing you to tailor the acoustic personality of every object in your scene.