Skills

Bevy Combat System

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

Install

npx skills add thedivergentai/Game-Dev-Agentic-Skills --skill bevy-combat-system -g -a claude-code -y
Category
Engineering
Updated
19d ago
License
LGPL-3.0
Context cost
Mediumabout 2,180 tokens
Runs scripts
No, instructions only

What it does

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.

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

NeedBevy shape
HealthA component with current and max. Fields are yours.
Confirmed hitA message the health system consumes.
Hurt volumeA 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

[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.

#[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,
}
Read the whole SKILL.md on GitHub

More in Engineering