Health System
Health System
The Advanced Turret AI System comes with a lightweight HealthSystem component. It's used for targets like enemies or destructible objects that turrets interact with.
🩺 Overview
Attach HealthSystem to any GameObject you want to receive damage from turrets. It listens for hits and tracks current health.
This component works out of the box with the
TurretControllerandTurretProjectilescripts.
⚙️ Inspector Fields
Max Health
Total hit points before destruction
Current Health
Current HP (can be changed at runtime)
Fill Health On Start Up
If true, sets current HP to max when the scene loads
On Death (UnityEvent)
Fires when health drops below 0
💥 Taking Damage
Turret projectiles call:
enemyHit.Invoke(enemy, turretDamage);which triggers this internally:
This reduces health on the enemy’s HealthSystem. You can also call it from your own scripts.
🧨 Destroying Objects
The HealthSystem can auto-destroy objects via:
Call this manually or from the On Death event.
✅ Quick Setup
Add
HealthSystemto any GameObject you want turrets to damage.Enable
Fill Health On Start Up.(Optional) Connect the
On Deathevent to play VFX, sounds, or destroy the object.
💡 Don’t forget to tag these objects as
Enemyso the turret can detect and target them.
Last updated