Making sprinkles

In the Prefabs section, we created the Prefab for our sprinkle projectile. In this section, we will see how to make sprinkles move into the 2D space. In particular, we will learn how to create and use scripts in Unity for 2D game elements.

The projectile class

Since there might be different projectiles in our game that can be thrown against the sweet-tooth pandas, and not only sprinkles, we need to define a general class. All the different kinds of projectile will follow some general rules:

  • They move in a straight line
  • They carry information about how much damage they will inflict on the enemies

Whereas the first is identical for all the projectiles, the second depends on the specific kind of projectile that will be fired. So, we need ...

Get Getting Started with Unity 5.x 2D Game Development now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.