Health Pickup
Scene: DuckShooter_HealthPickup
Pickups 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
| Prefab | Setup |
|---|---|
DS_HealthPickup | Health Pickup with Amount 25 and Collectors set to the player. On Collected shows +25 through a Hitpoint |
DS_DamagePickup | A prefab variant of the green one with Amount -25, showing -25 |
- Each pickup also has a
DSProjectile(speed 3, damage 0) that moves it down on a non-kinematic Rigidbody without gravity, and aDSRotatorthat spins it. - When the pickup hits anything,
DSProjectiledestroys it and its On Impact spawns a splash through aSpawnableEffect. Only the ship collects it. - The scene’s
DSWavespawns a random pickup at each point along the top, one every 0.5 seconds.
🚀 The Ship
The ship is the same as in the Many Ducks 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
HealthPickup is a package component, so you can drop it on your own health packs as is. For ammo, shields or power-ups, derive from Pickup.