Animating hearts of the symbolic lives counter

In this recipe, we will discover how to animate the hearts of the symbolic lives counter made in the second chapter. In fact, we will use an Animator controller to handle the animation and use the Animation window to animate them. Also, we want to make all the hearts beat. As a result, the UI will be more dynamic and immersive.

How to do it...

  1. You might remember that when we attached the script created in the Creating a symbolic lives counter recipe in Chapter 2, Implementing Counters and Health Bars, we needed to assign different images (in this case, hearts) in the Inspector. Now select one of them, for instance, Heart1, and then open the Animation window.
  2. Click on Add Property, and Unity will ask ...

Get Unity UI Cookbook 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.