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.
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.
Click on Add Property, and Unity will ask you to choose a folder in which you want to save your animation and a name. Just choose one and click on Save.
Next, we should notice that Unity has added an Animator component to our image and filled the controller variable with a controller named Heart1...