Book Image

OUYA Game Development by Example

By : John Donovan
Book Image

OUYA Game Development by Example

By: John Donovan

Overview of this book

The OUYA console and development kit gives you the power to publish video games for the players, creating a console marketplace of the gamers, for the gamers, and by the gamers. Using the OUYA developer kit and the Unity3D game engine, even beginners with a captivating game idea can bring it to life with a hint of imagination. OUYA Game Development by Example uses a series of feature-based, step-by-step tutorials that teach beginners how to integrate essential elements into a game engine and then combine them to form a polished gaming experience.
Table of Contents (18 chapters)
OUYA Game Development by Example Beginner's Guide
Credits
About the Author
Acknowledgments
About the Reviewers
www.PacktPub.com
Preface
Index

Time for action – improving the camera


Right now, our camera always stays in the same place. This confines our game to a very small area. To extend this area a little bit, we'll use one simple line of code that will keep the camera trained on our marble constantly. Perform the following steps to expand the viewing area of the camera:

  1. Create a new C# script called TrackingCamera in your Scripts folder and open it up.

  2. Add the following variable to the script above the Start function:

    public GameObject objectToTrack;
    
    void Start ()
    {
      
    }

    The public keyword before the GameObject variable type makes the variable accessible to the Unity editor and other scripts. We'll use this accessibility to our advantage and tell the script to track the marble right in the editor without any additional code.

  3. Save the script and left-click and drag it onto the Main Camera object in your Hierarchy menu.

    In the new script pane on the camera's list of components, a slot for your public variable will appear just below...