Book Image

Unity 2D Game Development Cookbook

By : Claudio Scolastici
Book Image

Unity 2D Game Development Cookbook

By: Claudio Scolastici

Overview of this book

<p>Unity is a powerful game development engine that provides rich functionalities to create 2D and 3D games.</p> <p>Unity 2D Game Development Cookbook is a practical guide to creating games with Unity. The book aims to serve the purpose of exploring problematic concepts in Unity for 2D game development, offering over 50 recipes that are easy to understand and to implement, thanks to the step-by-step explanations and the custom assets provided. The practical recipes provided in the book show clearly and concisely how to do things right in Unity. By the end of this book, you'll be near "experts" when dealing with Unity. You will also understand how to resolve issues and be able to comfortably offer solutions for 2D game development.</p>
Table of Contents (15 chapters)
Unity 2D Game Development Cookbook
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

The Audio Source component


When a new scene is created in Unity, a Main Camera object is created as well, and included in the scene. This camera is responsible, by default, for displaying the actual game scene when we press the Play button in the Unity Editor. Among the components the camera comes attached with by default, there is a component named Audio Listener (you can check it out in the Inspector panel). This component allows sounds to be heard by the player through the built-in speakers of their device or through a headset.

The Audio Listener constitutes the receiving half of the audio system implemented in Unity, the other half (the source half) being another Unity component called Audio Source. While the Audio Listener is generally attached to the main camera in the scene, Audio Source is attached to game objects in the scene that emit sounds, be they short sound effects or long, looped background music. In other words, to hear game sounds in Unity, you need to have at least one...