Pickups

Pickup is the base for items collected on touch, such as health packs, ammo or power-ups. It handles the collecting; you decide what the pickup does.

Note

Pickup is abstract, so you can’t add it directly. Derive your own pickup from it, like DSHealthPickup in the Health Pickup example. See Pickups in the scripting reference.

🧱 Setup

  1. Add your pickup script to a GameObject with a trigger collider.
  2. Make sure the collector, or the pickup, has a Rigidbody so the trigger fires.

📐 Inspector Overview

FieldDescription
On Collected (GameObject)Raised when the pickup is collected, with the collector. The collector is the Rigidbody’s GameObject when the collider has one

⚙️ How It Works

  flowchart LR
    A["Collider enters trigger"] --> B{"Apply accepts?"} -->|yes| C["On Collected, destroyed"]
  • When a collider enters the trigger, the pickup decides whether to accept it.
  • If accepted, On Collected fires and the pickup is destroyed.
  • A pickup is collected only once, even if several colliders touch it at the same time.

Tip

Hook On Collected to a Sound Generator or a Hitpoint’s ShowText for feedback.