Book Image

Creating E-Learning Games with Unity

By : David Horachek
Book Image

Creating E-Learning Games with Unity

By: David Horachek

Overview of this book

Table of Contents (17 chapters)
Creating E-Learning Games with Unity
About the Author
About the Reviewers

Building an interactive object

With these requirements in mind, let's build the framework for an interactive object that can be collected by the player.

Implementing the CustomGameObj script

We will begin with the CustomGameObj class. This class allows us to specify how an interactive object will behave when placed in the inventory, by giving it a unique type that is relevant for our game. Create the script by performing the following steps:

  1. Start from the codebase built in Chapter 1, Introduction to E-Learning and the Three Cs of 3D Games, to create a new subfolder in the assets folder named Chapter 2.

  2. Using the new script wizard, right-click on it and create a new C# script named CustomGameObject.

  3. We will also add a public enumerated type to this class called CustomObjectType. If you recall, an enumeration is just a list of identifiers of the integer type that share a common logical relationship with one another, such as the types of an object! Not only will this make discerning the type of...