With these requirements in mind, let's build the framework for an interactive object that can be collected by the player.
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:
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 namedChapter 2
.Using the new script wizard, right-click on it and create a new C# script named
CustomGameObject
.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...