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

PrefabSetup
DS_HealthPickupHealth Pickup with Amount 25 and Collectors set to the player. On Collected shows +25 through a Hitpoint
DS_DamagePickupA 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 a DSRotator that spins it.
  • When the pickup hits anything, DSProjectile destroys it and its On Impact spawns a splash through a SpawnableEffect. Only the ship collects it.
  • The scene’s DSWave spawns 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.