Week Four

Using Unity, we learnt how to implement triggers in our game worlds.

Using the scripts

function OnTriggerEnter (col : Collider) {

audio.Play();

}

and

function OnTriggerEnter (col : Collider) {

audio.Play();

}

function OnTriggerExit (col : Collider) {

audio.Stop();

}

you can control how you want the sound to react in your environment.

Trigger 1
Screen Shot 2015-03-04 at 14.33.32

In very basic terms, I created a small house/room and put an invisible square inside of it (by unticking the mesh render). You can then drag and drop the script onto the cube and the trigger script menu will appear at the side.
You then right click the cube and add an audio source. Another menu will then appear at the side where you can drop your audio clip on to.
To import audio you have to import it as an asset.

This trigger would be useful for when you either have to interact with objects or just generally if you need an object to constantly be making a sound.
You can toggle the option to play on awake or not. This gives you the option to manually trigger the sound or not, which is useful.


Trigger 2

Screen Shot 2015-03-04 at 14.39.01

Very much similar to the other trigger, trigger 2 simply starts the sound when you enter/interact with the trigger and will stop playing when you leave the trigger.
This would be helpful if you wanted particular music to start playing when you enter an area (e.g. creepy ambient noises if you were in the woods or some crazy drum and bass if you walked into a monsters lair)

Recent Posts