Game Development Reference
In-Depth Information
Tips and Tricks
Usually the errors are things like forgetting to close parenthesis or
forgetting the “;” at the end of a statement. Computers are pretty stupid
when it comes to writing script/code and can't interpret what you
mean—it has to be exactly right. Just be prepared to go back in and
double-check things in the script if Unity complains.
Step 25: Apply the script to Sound-Footsteps. Once there are no errors,
drag SoundFootstepsControl from the Project panel, up onto the Sound-
Footsteps GameObject in the Hierarchy. This script will now appear in the
Inspector if Sound-Footsteps is selected.
Step 26: Play and test. What should happen is every time the player
moves forward, backward, or side to side, the sound clip of the footsteps
will play. You can visually see this if you have the Inspector open for
Sound-Footsteps. Notice how the Audio Source checkmark turns on and
off when you push your A, D, S, and W buttons.
Conclusion
There it is. A short look at how Unity deals with sound. Pretty straightforward, eh?
Now of course, there are lots of details that can further enhance the power
of sound. Just the specifics of how a sound attenuates (drops off in volume
controlled via the Rolloff Mode settings for an Audio Source) based upon
how far away the player is from the source can add tremendous interest to
sound. However, in most situations, the baseline settings for Audio Source
with a bit of adjustments to the Min Distance and Max Distance does
the trick.
Don't cheat yourself on sound. Although the tools to control sound are fairly
quick and straightforward, a good sound design can do a lot for a game.
Spooky games are made downright scary with effective Foley (sound effects),
and an adrenaline-inducing first-person shooter can be made even more
intense with the right collection of sounds. Give it some love and sound will
help take your games to new levels.
In the next chapter we'll start looking at adding some real interactivity to the
game via a GUI.
Homework and Challenges
Challenge 1: Create a sound design for Hallway.
 
Search WWH ::




Custom Search