Book Image

Unity Game Development Scripting

By : Kyle D'Aoust
Book Image

Unity Game Development Scripting

By: Kyle D'Aoust

Overview of this book

Table of Contents (17 chapters)
Unity Game Development Scripting
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

The projectile item class


It is time for our final item class, which is the projectile item class. These kinds of items could be bullets, arrows, thrown items, and so on. The projectile item class will be similar to the melee item class, except this one will have functions that will allow it to move in the game world. We'll start by creating a new script and naming it itemRanged.

Adding our variables

As we did in the previous two classes, we'll need to first add a few enums to our script. Add these variables to our script:

public enum RangedAction {BuffDebuff, ChangeHP, ActivateEnv, None};
public enum RangedType {Weapon, None};
public enum MovementType {Basic, Drop, None};

You can see that we have a couple of familiar variables that we will use for the action and type of the item. We also have a new enum; this one will be used to determine how the object will move when it's created. The basic type will move the object through the air with simple movement. The drop type is similar to the basic...