In this recipe, we will go even further than we went in the previous recipe. Here, we will see how we can control the Animator controller through a script. In this specific case, you will learn how to change the speed of the controller according to the number of lives that the player has left. In fact, we want to make the hearts beat at a normal speed when the player has all his lives intact and beat faster when the player has fewer lives.
In order to get started, you should have completed the previous recipe, Animating hearts of the symbolic lives counter, because you need to have all the hearts animated through an Animator controller, called HeartAnimationController.
So first of all, we need to be sure that all the hearts have an Animator component attached along with the Controller variable filled by HeartAnimationController.
Since we need to change the Animator component through the script...