Consider this Unity C# script attached to a GameObject with an AudioSource component. What will be the audible effect when the player moves away from the source?
using UnityEngine; public class SpatialAudioTest : MonoBehaviour { void Start() { AudioSource audio = GetComponent<AudioSource>(); audio.spatialBlend = 1.0f; // fully 3D audio.minDistance = 1f; audio.maxDistance = 10f; audio.Play(); } }
Think about what minDistance and maxDistance control in 3D audio.
Setting spatialBlend to 1 makes the audio fully 3D. The minDistance is where the sound is at full volume. Beyond maxDistance, the sound fades out to inaudible.
In Unity's 3D audio system, which property determines how quickly the sound volume decreases as the listener moves away from the source?
It controls the shape of the volume drop-off curve.
rolloffMode sets the curve type (Logarithmic, Linear, or Custom) that controls how volume fades with distance.
Examine the following Unity C# script. The AudioSource component is attached and has an audio clip. Why does no sound play?
using UnityEngine; public class AudioDebug : MonoBehaviour { void Start() { AudioSource audio = GetComponent<AudioSource>(); audio.spatialBlend = 1.0f; audio.minDistance = 5f; audio.maxDistance = 15f; audio.Play(); } void Update() { transform.position = new Vector3(100, 0, 0); } }
Check the position of the audio source relative to the listener.
The script moves the audio source to position (100,0,0), which is far beyond maxDistance (15). The sound volume fades to zero and becomes inaudible.
Choose the correct Unity C# code snippet that sets an AudioSource to fully 3D and applies a custom rolloff curve.
Remember that spatialBlend must be 1 for full 3D and the curve must go from volume 1 to 0.
Option A correctly sets full 3D spatialBlend, sets rolloffMode to Custom, and applies a linear curve from volume 1 at distance 0 to volume 0 at distance 1.
You want to simulate the Doppler effect on a moving audio source in Unity. Which code snippet correctly enables and configures this effect?
Doppler effect requires velocity information from Rigidbody for accurate simulation.
Setting dopplerLevel to 1 enables the effect. spatialBlend must be 1 for 3D audio. Rigidbody velocity is needed for Doppler calculations.