- Unity 2018 Cookbook(Third Edition)
- Matt Smith
- 276字
- 2025-02-23 18:56:39
How to do it...
Follow these steps to simulate the sonic landscape of a tunnel:
- Create a new Unity 3D project.
- Import the provided Unity package, ReverbZone, into your project.
- From the Project panel, open reverbScene – it's in the _Scenes folder in the ReverbZones folder. This scene gives you a tunnel, and a controllable character (W A S D keys and Shift to run).
- From the Project panel, drag the Signal prefab into the Hierarchy – it's in the _Prefabs folder in the ReverbZones folder. This will add a sound-emitting object to the scene. Place it in the center of the tunnel:

- Make five copies of the Signal GameObject and distribute them throughout the tunnel (leaving a copy just outside each entrance):

- In the Hierarchy panel, use the Create menu | Audio | Audio Reverb Zone to add a Reverb Zone to the scene. Then place this new GameObjct in the center of the tunnel.
Use menu GameObject | Move To View if there is already a GameObject where you want to position another one. Since our Signal GameObject is in the middle of the tunnel, we can double-click that GameObject, then single-click Reverb Zone and move to view – to move the Reverb Zone object to the same location.
- Select the Reverb Zone GameObject. In the Inspector panel, change the Reverb Zone component parameters to these values: Min Distance = 6, Max Distance = 18, and Preset = StoneCorridor:

- Play the scene. As you walk through the tunnel, you will hear the audio reverberate when inside the Reverb Zone area.