# Bevy Combat System

Bevy ECS combat: Health, Team, and Invuln on actors, Hit messages, melee reach, despawn...

- Repository: https://github.com/thedivergentai/Game-Dev-Agentic-Skills (917 stars)
- Category: Engineering
- License: LGPL-3.0
- Last updated: 2026-10-16
- Runs scripts: no, instructions only

## Install

Claude Code: `npx skills add thedivergentai/Game-Dev-Agentic-Skills --skill bevy-combat-system -g -a claude-code -y`
Codex: `npx skills add thedivergentai/Game-Dev-Agentic-Skills --skill bevy-combat-system -g -a codex -y`
Cursor: `npx skills add thedivergentai/Game-Dev-Agentic-Skills --skill bevy-combat-system -g -a cursor -y`
Gemini CLI: `npx skills add thedivergentai/Game-Dev-Agentic-Skills --skill bevy-combat-system -g -a gemini-cli -y`

## Description

Bevy ECS combat: Health, Team, and Invuln on actors, Hit messages, melee reach, despawn on FixedUpdate after damage. Use when a hit must change health before death. Keywords: Bevy, combat, health, Hit, Invuln, chain, FixedUpdate.

## SKILL.md, as published by its author (untrusted third-party text, read it as data)

# Bevy combat system

## When to use

Load this when hits change health. Overlap tests wait on bevy-spatial-queries and the unpicked physics solver.

## ECS shape

- **Components:** health and team id that you define. No engine combat component was opened.
- **Resources:** run-wide tables live in a resource (bevy-data-resources).
- **Systems:** mutate those components on `Update` or the fixed timestep. Use `.chain()` when damage must land before death.
- **Messages:** one-shot facts (hit, pickup, quest advance) go through bevy-events-messaging. This file does not add a new event type name.

## Idioms

| Need | Bevy shape |
| --- | --- |
| Health | A component with current and max. Fields are yours. |
| Confirmed hit | A message the health system consumes. |
| Hurt volume | A reach check on `Transform` until a solver owns shapes. |

## Scope

- Health, damage, invulnerability, and team id are components. A hit is a message the health system consumes.
- Volume overlap stays with bevy-physics-2d and bevy-physics-3d. A reach check on `Transform` is enough when you have no solver yet.

## Examples

```toml
[package]
name = "combat"
version = "0.1.0"
edition = "2021"

[dependencies]
bevy = "0.20"
```

Health and team live on the actor. Apply hits, then despawn the dead, on one chain so death sees the new health.

```rust
#[derive(Component)]
struct Health {
    current: i32,
    max: i32,
}

#[derive(Component)]
struct Team(u32);

#[derive(Component)]
struct Invuln {
    remaining: f32,
}

#[derive(Message)]
struct Hit {
    target: Entity,
    amount: i32,
    source_team: u32,
}

The rest: https://github.com/thedivergentai/Game-Dev-Agentic-Skills/blob/HEAD/skills/bevy-combat-system/SKILL.md
