How can I create a health bar that always faces the camera?

Avatar
  • updated
  • Answered

Hi, I'm trying to implement a health bar on top of my enemy objects in a 3D world.  Please see below for an example.  I would like to make it such that the health bar is always facing the camera.  I have tried to set my Line component such that the Geometry is set to Billboard, but the health bars, which are parented to the enemy, simply rotate in whatever direction the enemy is facing instead of facing the camera.  Am I misunderstanding the purpose of billboards?  Do I need to create my own custom script?

Here's a video (starting at 0:10) of what happens when I set the Geometry to Billboard and parent to the enemy GameObject.

HealthBars — Kapwing

EDIT: I have created my own custom script such that the health bar will face the camera.  Still, I am curious.  What does setting the Geometry to Billboard actually do?

Reporting a bug? please specify Unity version:
Reporting a bug? please specify Shapes version:
Reporting a bug? please specify Render Pipeline:
URP
Pinned replies
Avatar
Freya Holmér creator
  • Answer
  • Answered

Billboarded lines don't modify the points in the line - they render a flat 2D line, but it pivots around the axis of the line itself to face the camera, but it doesn't rotate or change the start/end points


If you want the entire healthbar to billboard, you'll need to rotate the game object itself like you mention, using a custom script

Avatar
Freya Holmér creator
  • Answer
  • Answered

Billboarded lines don't modify the points in the line - they render a flat 2D line, but it pivots around the axis of the line itself to face the camera, but it doesn't rotate or change the start/end points


If you want the entire healthbar to billboard, you'll need to rotate the game object itself like you mention, using a custom script