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 – scripting the collectible


The first thing we'll script is some basic movement. Typically, the collectibles in games have some basic animation to differentiate them from the static objects in the scene, and it helps the player identify where they are. For our coin, just a constant rotation should suffice to make it stick out. Perform the following steps to script the collectible:

  1. Right-click on your Scripts folder in the Project window and create a new C# script named CoinRotation.cs.

  2. Double-click on the script to open it in your code editor. Add the following lines to the script's Update function:

    void Update()
    {
      gameObject.transform.Rotate(0, 0, 5);
    }

    These lines access whatever the GameObject script is attached to and call the transform property's Rotate function, which takes three parameters (one for each axis of rotation). We want to rotate our coin along the z axis, so we added a value of 5 in the Z axis parameter field and left the other values as 0.

    Tip

    The transform...