O'Reilly logo

Unity Character Animation with Mecanim by Jamie Dean

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

Adding and implementing collectable objects

Typically, in a game, the player will be able to collect power-ups to increase their effectiveness, or to replace depleted life or energy.

In this game, our player will collect food to boost his health. This stage will involve adding a collectable and making the player react with a suitable animation sequence.

Instantiating the lunchBox collectable in the game level

Our first collectable is already set up as a prefab in the project files, making it easy to drag and drop into our game level without having to add components and set variables:

  1. In the Project panel, locate the PACKT_Prefabs folder.
  2. Click to expand the Pickups subfolder and locate the lunchBox prefab.
  3. Drag lunchBox into the Hierarchy panel to instantiate ...

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