Health Pickup

Scene: DuckShooter_HealthPickup

A small pickup system for health and damage. Instead of ducks, green and red pickups rain down from the top of the screen, and the ship collects them by flying into them. A health bar shows the ship’s health.

  flowchart LR
    G[Green pickup] -->|+25| H((Ship Health))
    R[Red pickup] -->|-25| H

🎁 The Pickups

PrefabSetup
DS_HealthPickupDSHealthPickup with Amount 25, a trigger collider, a Hitpoint that shows +25 and a splash effect on On Collected
DS_DamagePickupA prefab variant of the green one with Amount -25, showing -25
  • DSHealthPickup derives from Pickup. A positive Amount heals, a negative one hurts.
  • After it’s collected, the pickup destroys itself. If it reaches the floor first, it’s destroyed without being collected.

🚀 The Ship

The ship is the same as in the Simple scene, plus a health bar: the ship’s On Health Changed sets a UI slider’s value.

Note

Healing goes through Health.Heal, so it ignores Invincibility. Damage goes through Health.Hurt, so spawn protection blocks red pickups.

Tip

Copy DSHealthPickup as a starting point for ammo, shields or power-ups: only Apply needs to change.