Create Health and Damage Pickups

Create Health and Damage Pickups

๐ŸŽฏ Goal

Make items that heal or hurt whatever touches them.

๐Ÿงฐ What You Need

  • A GameObject with a collider
  • Health Pickup
  • A Rigidbody on the pickup or on the collector

๐Ÿชœ Steps

Create the pickup object

Make a GameObject with a model and a solid (non-trigger) collider. Pickups work on collisions, and Unity only sends them when one of the two objects has a non-kinematic Rigidbody. If your player is kinematic or has no Rigidbody, give the pickup a Rigidbody, turn off Use Gravity and freeze its position and rotation so it stays in place.

Add Health Pickup

Add Add Component > Glowing Rifts > Modular Health > Health Pickup and set Amount. A positive amount heals, a negative one hurts.

Pick who can collect it

Set Collectors to the layers that can collect it, for example Player. The object it touches also needs a living Health on itself or a parent.

Choose if it stays

Keep Destroy On Collect on for health packs that are used up. Turn it off for hazards such as spikes or lava, which hurt again on every new touch.

๐Ÿ“ Inspector Settings

FieldWhat it doesSet it to
AmountHealth change on collect. Negative hurts25 for a health pack, -25 for a damage pickup
CollectorsLayers that can collect the pickupYour player’s layer
Destroy On CollectDestroyed on collect and on colliders without a RigidbodyOn for packs, off for hazards
On CollectedInvoked with the collectorA sound, an effect or Hitpoint.ShowText

๐Ÿงช Example

The Health folder has two ready-made pickups: Health Pickup (Amount 25, Collectors Player) and Damage (Amount -100, every layer, Destroy On Collect off).

In the Health Pickup scene, DS_HealthPickup (Amount 25) and its variant DS_DamagePickup (-25) rain down on the ship. Their On Collected shows +25 or -25 through a Hitpoint. The ship’s Rigidbody is kinematic, so each pickup has its own non-kinematic Rigidbody without gravity.

๐Ÿ’ก Tips

  • A health pack is collected even when health is full. To leave it for later, write your own pickup that returns false when health.isFull.
  • With Destroy On Collect on, the pickup is also destroyed when it hits a collider without a Rigidbody, such as the floor. Falling pickups clean themselves up.
  • Healing skips modifiers, but damage goes through Health.Hurt, so Invincibility blocks damage pickups. Hitbox multipliers never apply.

๐Ÿ”— Related