In this Unity 6 tutorial (2026), you'll learn how to create a player health bar step-by-step! I’ll show you how to:
Add a slider health bar to your player character.
Set up a world-space canvas and make the health bar always face the camera using a simple script.
Create a player health system that updates the UI dynamically.
Add basic damage detection where the player loses health when hit by a sword.
🔧 What you’ll learn:
How to create and design a health bar in Unity
Scripting a player health system using sliders and text
Rotating UI elements to always face the camera
Implementing damage mechanics and showing health in real-time
By the end of this video, you'll have a fully functional player health bar with damage detection in Unity! Perfect for your RPG, shooter, or any game requiring a health UI.
Don't forget to like, comment, and subscribe for more Unity tutorials!
👉 Try TEXT TO 3D AI for FREE (+ 3 day free trial for Pro plan): https://www.meshy.ai/?via=SoloDevTom
This video contains affiliate links. By using my links, you’re supporting my channel, as I earn a small commission.
Chapters:
0:00 - Intro: Overview of creating a health bar in Unity
0:17 - Designing the Health Bar with Unity UI (Creating the Slider)
3:00 - Rotating World Space Canvas Toward the Camera (UI Facing Camera)
4:58 - Health Bar Script: Setting Up the Health System
7:50 - Detecting Sword Hits in the Health Bar Script (Damage Detection)
8:18 - Adding a Sword with Box Collider and Tag Settings
9:55 - Handling Health = 0: Playing Death Animation and Hiding Health Bar
12:06 - Final Product: Recap and Testing