Skip to main content
‹ Back to Tutorials
Intermediate Unity

Unity and Playmaker 11 - Health Manager, Player Death, Game Over

Nov 15, 2020
About this tutorial

Hi I'm Jerry from Bliz Studio LLC. Health, Death, Game Over. Yep, I'll be covering all of those in this video so get your mouse and keyboard out and get ready to make a Health Manager in Unity and Playmaker along with Player Death and a Game Over event. How to Make a Video Game With Unity3D and Pl

Written Guide

A health system touches almost every part of a game: UI, collisions, state management, and game-over flow. This guide rebuilds the video's full setup for the 2D space shooter — three hearts, a Health Manager FSM in Playmaker, an explosive player death, and a working reset button.

Step 1 — Draw the heart graphics

In Photoshop, create two layers named ui-heart.png and ui-heart-outline.png — with File > Generate > Image Assets enabled, any layer named with a file extension auto-exports on every save. Draw an angular heart in orange-red, then for the outline use Select > Modify > Expand (3 px) and Edit > Stroke set to Outside. Use a slightly off-white rather than pure white; pure white on black is harsh on the eyes. A handy trick from the video: Window > Arrange > New Window opens a second zoomed-out view of the same document so you can pixel-edit and preview simultaneously.

Step 2 — Build the health UI

Import both sprites into a new Sprites/UI folder, then create a dedicated canvas named UI - Health. Add three outline images next to the score (keep UI grouped in one corner so players read everything in a glance), then three filled hearts named Heart 1, Heart 2, and Heart 3. The outlines stay on permanently; the fills are named individually because the FSM will toggle them off by name.

Step 3 — Health Manager and physics fixes

Under your Game Managers object, add an empty GameObject with an FSM renamed Health Manager (never leave FSMs with the default name — you'll need to target them specifically later). Create a global int variable called health, starting at 3. The player also needs working 2D physics: a Box Collider 2D with Is Trigger checked, a Rigidbody 2D (mass 1, gravity 0) replacing the 3D Rigidbody, and Set Velocity swapped for Set Velocity 2D — with Every Frame checked, or the ship reads input once and never moves. Tag the player as Player; enemies should already carry the Enemy tag.

Step 4 — Listen and branch on health

The FSM's listener state uses a Trigger 2D Event watching the rocket; on collide with the Enemy tag it sends a remove health event into a check state holding three Int Compare actions. Health 3, 2, or 1 routes to Remove 3, Remove 2, or Remove 1. Each removal state deactivates its heart with Activate Game Object, uses Set Int Value to drop health by one, and sends shake medium to the main camera via Send Event By Name before looping back to the listener.

Step 5 — Game over, reset, and polish

The final hit activates a UI - Game Over canvas — a semi-transparent black panel with TextMesh Pro text, sort order set to 10 so it renders above the other canvases — plus a shake big, an explosion particle (copied from the enemy, repositioned to 0,0 on the rocket), and a 1-second Wait before deactivating the player so the explosion actually plays. A separate Reset Game FSM with a global game reset transition reverses everything: game over off, spawner and rocket back on, all three hearts on, health set to 3. The reset button triggers it through a UI Button On Click Event. For extra feedback, an orange screen-flash panel activates for 0.2 seconds on each hit — turned off in its own separate state, since doing it all in one state fires too fast to see.

Unity tools by Bliz Studio
Built for our own games — now on the Asset Store

Multi Tag — unlimited hierarchical tags for any GameObject. Hierarchy Pro — style your whole hierarchy with rules. Made by a Unity dev, for Unity devs.

Explore our Unity assets →