Spielerando

Health Regeneration

Health regeneration lets a character heal by itself once it has been left alone for a few seconds. Every hit restarts the wait, and the healing eases in instead of snapping on. It stops at a ceiling that can sit below full, and it never brings back a character who is down.

Also called: Regenerating health, Auto-heal, Self-healing, Recharging health, Health recovery.

A small knight made of tin cans crouches behind a broken pillar while green sparkles close the cracks in its armour, and a stone gargoyle across the courtyard turns away.
Tinplate Vigil, an invented pixel-art action adventure. Invented game, image generated with AI.

Paste this to your AI

Copy it into Claude, Cursor or ChatGPT. It already has good values and the usual mistakes in it.

Add "Health Regeneration" to my game.

What it should do: Self-healing lets the player take a risk, retreat and recover, instead of hunting for medical kits. It rewards stepping out of the fight, and the wait stops it from making every hit free.

Build it exactly as this state machine. First check that it fits my game, then build it like this:

```mermaid
stateDiagram-v2
  [*] --> full
  full: Healthy
  wait: Waiting
  heal: Healing
  down: Down
  full --> wait: takes a hit
  full --> heal: hit, with no wait
  full --> down: knocked out
  wait --> heal: wait is over
  wait --> full: item restores health
  wait --> down: knocked out
  heal --> wait: takes a hit
  heal --> full: health restored
  heal --> down: knocked out
  down --> [*]
```

Use these starting values:
- maxHealth: 100 units
- regenRate: 12 units/s
- regenDelay: 4 s
- rampTime: 1.5 s
- regenCeiling: 1 share of full

Watch out for these common mistakes:
- Healing brings back the dead: Tell your AI: when health is zero, healing by itself does nothing. Only an item or a respawn can bring a character back.
- Healing in the moment of a hit: Tell your AI: when a hit lands, restart the wait and the easing, and do not heal in that same moment.
- Fast computers heal faster: Tell your AI: heal by speed times the seconds that passed, and when a frame is long, count only the seconds after the wait.
- A heal item is lost at the ceiling: Tell your AI: the ceiling only stops regeneration. Never lower health that is already above it.
- A hit of zero holds healing back: Tell your AI: only a hit above zero restarts the wait. Zero, below zero or something that is not a number does nothing.

Do not change anything else in the game. Do not claim anything without proof: model what it takes, and show me what your solution rests on and how I can see that it works. If you cannot show something, say you do not know. When you are done, tell me in plain words how to try it.

Or skip this and connect the MCP: your AI then finds all of this by itself.Connect the MCP

What it does

Self-healing lets the player take a risk, retreat and recover, instead of hunting for medical kits. It rewards stepping out of the fight, and the wait stops it from making every hit free.

How it runs, as a diagram

Everything it can be in, and what moves it on. Your AI builds from exactly this.

takes a hithit, with no waitknocked outwait is overitem restores healthknocked outtakes a hithealth restoredknocked outHealthyWaitingHealingDown
How it runs, as a diagram
  • Healthy → Waiting: takes a hit
  • Healthy → Healing: hit, with no wait
  • Healthy → Down: knocked out
  • Waiting → Healing: wait is over
  • Waiting → Healthy: item restores health
  • Waiting → Down: knocked out
  • Healing → Waiting: takes a hit
  • Healing → Healthy: health restored
  • Healing → Down: knocked out

Good starting values

ValueStart withWhat it changes
maxHealth100 unitsHow big the full health is. Hits and healing are best read as shares of this number.
regenRate12 units/sHow fast health comes back at full speed. At the starting values a character at one tenth of health is back to full in about ten seconds after the wait. It is never zero, because the character could not recover.
regenDelay4 sHow long the character must go without a hit before healing starts. Four seconds is long enough that standing in the open costs something, and short enough that taking cover works.
rampTime1.5 sHow long healing takes to reach full speed. A slow start makes the first moments after cover feel safer without a jump in health. At zero it starts at full speed.
regenCeiling1 share of fullThe share of full health that regeneration reaches. Below one, some damage stays until the player finds an item, which makes long fights wear the player down.

What usually goes wrong

Healing brings back the dead

A character at zero health is also healed by the timer, comes back, and walks on after a death screen was already shown.

Fix: Tell your AI: when health is zero, healing by itself does nothing. Only an item or a respawn can bring a character back.

Healing in the moment of a hit

The healing and the hit land in the same moment, so the player takes less than the hit says, or the wait never starts.

Fix: Tell your AI: when a hit lands, restart the wait and the easing, and do not heal in that same moment.

Fast computers heal faster

Healing adds a fixed amount per frame, so a computer running at 144 frames a second heals more than twice as fast as one running at 60.

Fix: Tell your AI: heal by speed times the seconds that passed, and when a frame is long, count only the seconds after the wait.

A heal item is lost at the ceiling

The ceiling is set below full, a medical kit lifts health above it, and the next moment health is cut back to the ceiling. The player wasted the item.

Fix: Tell your AI: the ceiling only stops regeneration. Never lower health that is already above it.

A hit of zero holds healing back

A poison or a fire that deals zero damage in some moments still restarts the wait. The player never heals, and cannot tell why.

Fix: Tell your AI: only a hit above zero restarts the wait. Zero, below zero or something that is not a number does nothing.

How to check it works

Works well with

Common questions

how does health regeneration work in games

After a few seconds without a hit, health starts to come back by itself. Every new hit restarts the wait. Most games ease the healing in and stop it at full or at a ceiling.

how long should the wait before regeneration be

Start with about four seconds. Shorter makes hits almost free, longer makes the player hide for a long time.

should health regeneration go all the way to full

It can, and it keeps the game moving. Stopping at a lower ceiling, such as half, makes a long fight wear the player down until they find an item.

what do i tell my ai to add health regeneration

Paste this: Add health regeneration. After 4 seconds without a hit, health comes back at 12 per second, easing in over 1.5 seconds. Every hit restarts the wait. It never heals a character at zero and never lowers health above its ceiling.

Where it comes from

We could not find a reliable origin for this one yet.

Where this mechanic comes from has not been researched yet.

Games are named only as references. Names and marks belong to their owners, and nothing here is endorsed by them.

What was checked

This is what separates the blueprint from a catalogue entry: the values on this page come from code that runs.

Your AI gets the code

Tested example code comes through the Spielerando connection, so your AI can use it right away. How to connect it