O'Reilly logo

Getting Started with Unity 5.x 2D Game Development by Francesco Sapio

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

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

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