Skip to content

TheFunnyBrain/DirectionalAudioSwitcher

Repository files navigation

DirectionalAudioSwitcher

A small bit of Unity code to crossfade snapshots based on which audiosource the player is facing.

image

How to use:

Audio Source and Mixer Groups

  • This script uses Camera.Main (got once in the start method). You'll need a camera tagged as "MainCamera".
  • Make Mixer groups for each audio source you'll be controlling.
  • Assign these mixer groups in the audio source's inspector. image
  • Position your sources in different places, I did mine north, south, east, and west.

Mixer Snapshots

  • Make snapshots for each source, where everything except its group are turned down fully. image

Component Setup

  • Add a DirectionalAudioSnapshotSwitcher
  • I've made a right click context menu on the DirectionalAudioSnapshotSwitcher component, this will set up 4 snapshot entries for North, South, East, and West. Totally optional, but a timesaver for this example use case. image
  • Assign the fields for each AudioSnapShotData in the inspector (e.g.the transform for the north audio source, and north snapshot) image

Hopefully press play, and you'll see changes when you turn the camera (either through a player script, VR, or grabbing the transform in scene view.

About

A small bit of Unity code to crossfade snapshots based on which audiosource the player is facing.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages