Member-only story
RTS Interlude #4: Improving the healthbars (Unity/C#)
Let’s digress for a while and leverage the power of shaders in our RTS game!
⬅️ Tutorial #49: Optimisation tips & tricks| TOC | Tutorial #50: Implementing a technology tree 1/3 ➡️
📕 Get the ebook and bonus material on Gumroad!
🚀 Find the code of this tutorial series on my Github!

In previous episodes of the series, we talked a bit about how to create healthbars for our units. In particular, we had some logic to create a UI element and “snap it” above the head of the unit.
However, this technique is pretty flawed and not very efficient because:
- the healthbars can quickly get strange offsets
- we have to manually reposition them on the screen whenever either the camera or the unit moves, plus when the camera zooms
- we are deleting and re-creating objects (the UI healthbars) each time we select or deselect our units
All these are bad and power-consuming… but there is a solution to improve all of this! So, today, let’s do a retake on our healthbars and see how we can use shaders to display them efficiently, robustly and easily :)