Scripted Island – Ambiences [in Unity 3D]

I have created a few scripts in Unity 3D to testing purposes which are driving custom recorded sounds to build an audio atmosphere of small island. Scripts randomly trigger oneshot sounds and a couple of loops (wind, river and some other) to create non-repetitive audio background without use of long recordings. This also allows to position point sound sources, like birds at certain places in the enviroment which helps you to locate yourself in the world.

What’s scripted on the island:

  • Triggering sounds only when the Player is in the area
  • Scripted Island ScreenNighingale Birds Sounds on trees
  • Ocean waves near the shore
  • Spatialized sound of the river
  • Frogs in Ponds
  • Crickets around grass area
  • Wind blowing at the cliff (also spatialized)
  • Footsteps:
    – script automatically chooses apropriate footsteps set (ground, sand, stones, water, wood, metal etc.), coresponding  to terrain textures and detects collision with objects (bridges, water)
    – Shuffles steps playing order to alleviate repetitiveness (every set contains 10 to 50 sounds).

The sound files size  is 10 MB of ogg compressed data. 21 MB of all data to transfer and run online (Unity 3D Web Player is required. Update: Chrome Browser withdrew support for NPAPI plugins and Webplayer doesn’t work there anymore. Also in Opera browser. You need to use other browser like Firefox to run this).

To control movement use keys: WASD + Mouse to look around. To turn on the fullscreen mode click the icon in the bottom right corner.

Update info (06.2017): due to policy changes and lack of updates on Unity side, online example seems not to work in any of current browsers. Sorry.

Unity 4.x scripts are limited in a few places when you want to control Audio Source. For example you can use one of only two RollOff Curves (Linear or Logarithmic). Custom Rolloff Curve is not available when accessing from script. Overcoming such limitation isn’t complex so if you need different Rolloff to your sounds you can emulate it by feeding distance between Player and sound emitter to audio.volume manually.

Whith similar approach we can simulate if the sound in the Unity surrounds the player or not. Change gently Pan Level parameter of the Audio Source when player approaches near the object and see – I mean – listen to what happens with the sound (check the river in the island).