What
I need to research?
I need to find out how I can make the music
play within the game, for example when the game starts, the in game music needs
to play. I also need to work out how I
can make trigger points; these trigger points activate sound effects when the
vehicle comes into contact with the trigger point’s radius.
How
I’m going to research what I need to know?
The apple store provides/sells a tutorial video called game audio 102. This software can teach me everything I may need to know for our game.
The apple store provides/sells a tutorial video called game audio 102. This software can teach me everything I may need to know for our game.
If the information provided doesn’t make
sense or isn’t what I’m looking for, I’ll resort to surfing the Internet for
the answers.
Starting
my research.
I first researched into how I could just
simply import audio within Unity. Simply learning how to do this just helps me
gain an understanding into how unity’s layout, controls and options area’s work.
On the inspector bar on the right of unity
you can find audio listener. The audio listener works as the same functions as
your ears does, but within a 3D space. Only one listener is required and is
normally attached to an empty play object.
I first need to add an audio source; this
serves as the source of sound so unity knows which sound you want to use within
a 3D space. Once I have selected the audio I want to play/use, I then have to
apply it to an object, preferably an empty object that cannot be seen within
the game when in play mode. Once applied, I can then go into audio source under
components and select the audio clip I want to use. There I choose the
following options, (Play awake and Loop). Within the audio source I can choose
a range of options that can manipulate the audio from pitch to distance etc. It
is in here that I will be spending most of my time learning about audio in
Unity.
(Example of the layout within unity)
(Example of audio source control area)
How
to make the music play over in unity
I need to know how to make the music play
(Loop) within the game, this is so I can make the in game music play, while the
rally game starts.
To allow music to play within the game, all
I have to do is apply sound to the controller. The controller is the object
that the player moves and controls within the game, in our case it would be the
car, so I would apply our music in the same way I would when applying sound to
any object. This will allow the music to play when the game starts over and
over (because loop is selected) till the game is over. (When the controller
will deactivate).
How
to set up triggers in unity
Having triggers allows my voiceovers to
come into play for up coming corners in the game. I will place my triggers
before a corner or event, so that the player can hear the voice over, alerting
them in time for whatever is about to happen.
To do this I’m going to have to use collision
within Unity, this is when two objects intersect with each other, allowing the
game engine to know that two objects with collision scripting are both
programmed to have an event, in our case a sound effect.
I need to create an object that has a
collider; these are located in the component menu under physics. When a
collider is set to an object, I have to make sure the trigger’s option is
ticked to insure the colliders can work, this allows me to interact with any
game object within unity that also has a collider set to it.
Before it can actually work, I will have to
before anything use scripting within unity, this is something I didn’t think I
had to do when working with sound in unity, but scripting audio is an important
part of game engines. I will have to create a Java script within unity to allow
me to script/code what I need.
var Sound :AudioClip;
function OnTriggerEnter() {
audio.PlayOneShot(Sound) ;
}
}
This code tells the object to play the
sound that I want when the controller comes into contact with my objects
radius. In this code the audio.PlayOneShot(Sound) ; is set to play an audio
file named (sound), this is where I would type the actual audio files name that
I want to play within the trigger, for example, Easy right voice over etc. Now
I have scripted the code, all that is left to do is to copy and paste the
script into the object I wish to have a trigger point, this will allow the controller
when it comes into contact with my objects collider, to play a sound.
I must remember that the code audio.PlayOneShot
requires a source. So I must place my audio file whatever that is, over the
variable in my script and not the audio source for this to work properly.
(Please not all images in this research document are taken from audio 102 video tutorial)
(Example of a trigger point and it's radius)
(Please not all images in this research document are taken from audio 102 video tutorial)
What I’ve learned and gained
Having never used Unity before, I was
pretty worried about doing audio within a game engine, but from just simply
exploring and learning how unity layout works and is structured can help me
understand the format in which unity works. From watching audio 102 tutorials,
I feel I’ve gained a great understanding into how audio can work within Unity;
of course I would learn much more when the time comes for me to work in unity for
our game. But for now from the research done, I feel I am confident to say that
I know what I’m doing when it comes to Unity’s audio controls.
No comments:
Post a Comment