Programming Sound Triggers


Again with the sound I over-reached for my skill level. I again thought the audio would just be a matter of drag and drop – but it wasn’t at all. How the basic audio works is the character has an audio listener and you can place audio source into the scene as an invisible object. Unfortunately this plays the sound at the same volume no matter where you are in the scene from start to finish. This just wouldn’t work for triggering audio and placing multiple audio sources throughout the scene.

I ended up creating three C# Scripts:

(With help from outside source examples)

  • Audio that plays once when walk into
  • Audio that plays continuously once approached
  • Audio that plays only in a specific area.

The code connects the sound sources to the trigger collides in the scene so that when the character approaches the trigger the audio plays.

In future I would try and find a way to make the sound blend smoother and feather as you walk through the collider – I think it may just be a matter of changing the shape of the collider, but I could be wrong.

Oculus Rift: Virtual Reality Immersion

To create immersion for the scene I needed to add movement and sound. I explored how I can use code to move objects and create triggered objects.

Capture_11The movement was a lot easier than expected for the environment objects. Unity created public options such as the ‘wind’ effect to be able to manipulate and animate trees and grass. The only struggle I found was creating movement through the lighting and smoke. While the trees and grass moved, I wanted the smoke and lights to breathe.

Programming the Light Movement: Error

Capture_14For the lights I ran into issues when trying to animate them with code. As I’m not an advanced programmer I was hoping to use the default code to create flickering lights, but unfortunately the Unity engine had other ideas. This error came up when implementing it. At first I thought it was an error with the new Global illumin
ation feature
in the new update of Unity 5.1 I was working with, where some of the light doesn’t show up where its suppose to due to the reflection bounces.

Although after a long time of scrolling through the internet’s question and answer sites I discovered that the issue actually comes from Unity not being able to implement reflection bounces on spot and point lights. So when the code was applied the light just didn’t work at all.

Programming the Light Movement: Solutions

Capture_17The first solution I tried was to change the light mode to a directional light so that the code would work. Unfortunately that had harsh negative effects on my scene:

The lights flickered, but the directional light not only effected the entire environment no matter how small the intensity but i
t also entirely changed the mood of the scene. So I had to think of something else.

The next thing I could think of to do was change the code, create an entire new one. The idea of it was terrifying but a great learning curve.


Start to finish screen shots of the Unity Scene being created

Capture Capture_01

The first thing I did was model a simple map layout from my drawn concepts in Blender, then I imported it into Unity so I could test the scale and layout of the scene. I also used scale references provided by class tutorials to test the scale.

Capture   Capture_04 Capture_02

Next I added simple models to test the feeling of the environment when you move around. I also added the skybox for realism.  I found that I made a lot of changes here, the environment felt too empty and felt very fake. After adding the refined models and texture, it still wasn’t what I wanted. I tried to add more trees to fill up the environment background, but it was too many polygons and would have made the scene too heavy.

To solve this problem I created an image with Photoshop brushes to create the effect of having a silhouetted forest background. It took a while of playing around with position and tree density to get the desired feeling.

Capture_08 Capture_07

The next technique I used to add a fuller background was a complete failure.

In Maya, I tried to put together a scene that I could use as a rendered image, but due to my lack of knowledge in Maya with cameras and lighting it didn’t look good in the scene and I had to take it out.

Although looking at it now – It could have possibly worked if I didn’t change the lighting in Maya and left it natural. If I had more time I would go back and add it to the image.


Once I spent hours arranging the tree density and the size of the background images, I was now able to start adding more texture detail to my scene. To create the ground I used the Unity 3D terrain editor, and looked at references for environment design and how to fill the space.