Health Bars and Damage Numbers
A health bar is a rectangle with a width. The good ones have a second, lagging bar, ticks you can count and numbers that never pile into soup.

Key takeaways
- Use two bars: the real value snaps down instantly and a lighter chip bar follows after a 0.4 to 0.6 second pause, so every hit reads as a size.
- Store health as a number and draw it as a ratio. Many bugs come from mixing those two, such as bars that overflow when max health changes.
- Damage numbers rise 30 to 50 pixels over about 0.7 seconds, scale in from about 1.4x, and merge when hits land within a fraction of a second.
A good health bar shows two things at once: how much health is left and how much the last hit took. The trick that does both is a delayed chip bar: the real bar drops instantly, a lighter bar behind it holds for about half a second, then drains down to meet it. Pair that with damage numbers that pop out of the target, rise and fade within a second, and players can read every exchange of a fight without looking at the HUD for more than a glance.
Where the HUD should sit and what earns a place on it is covered in our HUD design guide. This article is about the two widgets themselves: how they are built, the values that make them feel right, and the bugs they cause.
Data first: health is a number, the bar is a ratio
Every combatant needs `hp`, `maxHp`, and for the bar, `displayHp` (what the chip bar is showing). The bar width is always `hp / maxHp × barWidth`, computed when drawn. Never store the bar width, and never let gameplay code write to the bar directly. Gameplay changes `hp`; the bar reads it.
- Clamp on every write. `hp = clamp(hp - damage, 0, maxHp)`. A bar drawn with negative width flips and draws backwards in some renderers.
- Decide what a max health change does. When an upgrade raises max health from 100 to 120, either keep the current value (80/120) or keep the ratio (96/120). Pick one on purpose. Forgetting gives 80/120 on one screen and a bar overflowing its frame on another.
- Keep fractions out of the display. Damage formulas often produce 12.6. Store the float, show `Math.ceil` so the player never sees 0 health while still alive.
- Overheal or shields are a separate value, drawn as a separate color extending past the end or overlaying the bar, never by letting `hp` exceed `maxHp`.
The chip bar, with numbers
Draw three rectangles: a dark background, a light chip bar at `displayHp`, and the real bar at `hp` on top. On damage, the real bar snaps. The chip bar waits, then catches up. Starting values:
- Hold before draining: 0.4 to 0.6 seconds. Long enough to see the chunk, short enough that it is gone before the next exchange.
- Drain time: 0.25 to 0.4 seconds, eased out, regardless of chunk size. Draining at a fixed speed makes big hits slow and small hits invisible.
- Reset the hold on each new hit. Rapid hits pile into one large chip that then drains together, which reads as a combo.
- Healing reverses the trick. A green or bright preview bar jumps up to the new value, and the real bar fills to meet it over about 0.3 seconds.
- Colors: the chip is a lighter or warmer version of the bar (white, pale yellow or light red), never a new hue the player has to learn.
Segments and ticks
Players count better than they estimate. Thin tick marks every 10 or 25 health points let players think 'I can take two more hits', which is the whole point of a health bar. For bosses, segment the bar by phase instead: a tick at 66 and 33 percent tells the player where the fight changes. Our boss fight guide goes into phases; the bar is where you announce them.
Low health warning
Below about 25 percent, change something besides the width: the bar pulses (a slow 1 to 1.5 second cycle), the color shifts, and many games add a faint red vignette at the screen edges and a heartbeat sound. Pulse, do not flash rapidly: a fast flash at low health is stressful and can be a photosensitivity issue.
Enemy bars above heads
- Hide them at full health. Show an enemy bar the first time it takes damage and fade it out 3 to 5 seconds after the last hit. A field of twenty full bars is noise.
- Size by importance. Regular enemies get a thin bar (3 to 5 pixels tall, about the sprite's width). Elites get a thicker one with a frame. Bosses move to a big screen-space bar at the top or bottom with a name.
- Anchor to the sprite's top, not its center. And offset by a fixed amount so the bar does not bob with the walk animation.
- Draw them above the world but below the HUD, and keep them out of camera shake if possible so they stay readable during a big hit.
Damage numbers that stay readable
Floating numbers turn invisible math into something the player can feel. They are also the fastest way to clutter the screen. Values that work for most action games at 720p:
- Spawn at the hit point, plus a small random horizontal offset of 8 to 16 pixels so consecutive numbers do not stack exactly.
- Pop: start at about 1.4x scale and settle to 1x over 0.1 seconds with a slight overshoot.
- Rise: 30 to 50 pixels over 0.6 to 0.9 seconds, eased out, then fade in the last third. An arc (a small sideways drift plus gravity) feels more physical than a straight line.
- Critical hits get a larger size (about 1.5x), a different color and a longer hold. Make crits distinct in shape or size, not only color, for color-blind players.
- Healing numbers are green with a plus sign and rise from the healed character.
- Merge rapid hits. If a target takes several hits within 0.2 to 0.3 seconds, add them to the number already on screen and re-pop it, instead of spawning a new one. A flamethrower dealing 3 damage twenty times a second should show one climbing number, not twenty.
- Cap the count. Keep at most 20 to 40 numbers alive at once and drop the oldest. Damage-over-time ticks and tiny hits can be skipped entirely.
- Format big numbers. In games with growing numbers, show 1.2K and 3.4M rather than 1,234 and 3,412,880. Our idle clicker guide has a number format worth copying.
The bugs these widgets usually cause
- Bar shows the wrong target. Pooled enemies reuse objects; if the bar keeps a reference to the old enemy's health, a fresh enemy spawns with a half-empty bar. Reset `displayHp` when an enemy is taken from the pool.
- Chip bar drains below zero or above the real bar. Clamp `displayHp` to at least `hp` every frame.
- Numbers in the wrong space. A number spawned in world space scrolls with the level, which is right; one spawned in screen space stays still while the world moves, which looks detached. Decide once: world space, drawn above everything.
- Text is slow. Creating a new text object per hit is expensive on phones, especially with outlines. Use a bitmap font and pool the number objects. See smooth web games on phones.
- Death before the bar finishes. If the enemy is removed the instant `hp` reaches zero, its bar and the killing number vanish with it. Let the death animation own the bar for a few frames, and let numbers live independently of their target.
How they combine with other mechanics
Invincibility frames make the bar flash in rhythm with the character, which tells the player why the next hit did nothing. Armor and resistances should show reduced numbers in a duller color and fully blocked hits as a small 'Block' word, so the player learns what works. Stamina usually sits directly under health with a different color and thinner height. Shields are a second bar layered over the first, and they should break with a distinct sound. In an RPG, numbers carry much of the combat feel, so they get more room; in a platformer with three hearts, use hearts instead of a bar entirely.
On Startbase, the UI Editor lets you move and restyle a game's HUD by hand, including the player's health bar on a HUD screen. Text that lives in the world, like damage numbers flying off an enemy, stays part of the game itself, so ask the agent to change those.
A brief to paste
Upgrade health feedback in my action game. Player bar top left, 200 px wide, tick marks every 20 HP. On damage the red bar drops instantly and a pale chip bar holds for 0.5 s, then drains to match over 0.3 s, resetting the hold on new hits. Healing shows a green preview that the bar fills into over 0.3 s. Below 25 percent the bar pulses slowly and the screen edges get a faint red vignette. Enemies show a thin bar only after their first hit, fading 4 s after the last one. Damage numbers spawn at the hit point with a small random offset, pop from 1.4x, rise 40 px over 0.8 s and fade; crits are 1.5x size and gold; hits on the same enemy within 0.25 s merge into one number. Max 30 numbers on screen, pooled, using a bitmap font. Expose the hold, drain, rise and merge window as dials.
Frequently asked questions
What is the delayed white or yellow part of a health bar called?
It is usually called a chip bar, ghost bar or damage trail. It lags behind the real value so players can see how big the last hit was.
Should enemies always show health bars?
Not at full health. Show a bar once an enemy is damaged and fade it a few seconds after the last hit. Bosses are the exception: they get a large dedicated bar for the whole fight.
Why do my damage numbers overlap into a blur?
Fast hits spawn numbers in the same spot. Add a small random offset, merge hits on the same target that land within about a quarter second, and cap how many numbers can exist at once.

