Combined timer and health UI


Rather than having mutliple UI components for showing the timer before the hero arrives and the heros health once he is there, I moved the health and timer UI components into the same region of the canvas and updated the show and hide animations so they appear in order.

This is done using using MMFeedbacks which is an old free library for adding game feel by reuno, but there is also new and maintained version in the Asset Store which comes with lots of support and demos, so go check that out!

Essentially I hide everything by setting the x and y transform scale to 0, then I have a scale effect that scales everything to 1 to show or 0 to hide along a bouncy curve to add to the fun.


Then I have several scripts and events that trigger hiding and showing when required.

public class HealthController : MonoBehaviour
{
  [SerializeField]
  private MMFeedbacks _showFeedbacks;
  private void ShowHealth()
  {
    if (_showFeedbacks)
    {
      _showFeedbacks.PlayFeedbacks();
    }
  }
  private void OnEnable()
  {
     HeroEvents.OnHeroEntered += ShowHealth;
  }
  private void OnDisable()
  {
    HeroEvents.OnHeroEntered -= ShowHealth;
  }
}

Its a bit more complicated than that, but you get the idea...

Want to see more?

All the code for this project is available publicly online. 

Get Tower Offender

Leave a comment

Log in with itch.io to leave a comment.