O'Reilly logo

Unity Game Development Scripting by Kyle D'Aoust

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required