Unity Health & Combat Scripts

4 free C# scripts 2 beginner2 intermediate Unity 2022.3+, 6000.0+ MIT licensed

Combat in Unity usually comes down to two questions: what can take damage, and what deals it. The Health System answers the first. It is one component with damage, healing, invincibility frames and UnityEvents for every change, so health bars, popups and death effects can listen instead of polling.

The other scripts deal the damage. The Projectile System moves, collides and can home in on a target, and the Weapon System defines melee and ranged weapons as ScriptableObject assets with cooldowns and ammo. Weapon System Pro adds combo chains, weapon switching and damage types.

Start with Health System

Reusable health component with damage, healing, invincibility frames, and events.

HealthSystem.cs · 7 Inspector fields · beginner

Open Health System
HealthSystem.cs
Script HealthSystem
Health
Max Health 100
Current Health 0
Invincibility
Invincibility Duration 0.5
Events
On Health Changed (float, float)
List is Empty
On Death ()
List is Empty
On Damaged ()
List is Empty
On Healed ()
List is Empty

All 4 health & combat scripts

What these scripts need

Read from each script's source, so this list stays in step with the code.

  • Reads the legacy Input Manager (UnityEngine.Input). If Project Settings > Player > Active Input Handling is set to Input System Package only, Unity throws an InvalidOperationException; set it to Both.

    2 of 4: Weapon System, Weapon System Pro

  • Defines a ScriptableObject asset: create one from Assets > Create > Weapons > Weapon Data.

    Applies to: Weapon System

  • Defines a ScriptableObject asset: create one from Assets > Create > Weapons > Weapon Data Pro.

    Applies to: Weapon System Pro

Kits that build on them

Guides that use them