Skip to content

🌍 Use / World

Simple 2D trigger-based pickup behaviours for demos and prototypes.
These show how to add items to inventory or trigger use-effects directly from world objects.


🧩 Purpose

Provide minimal, ready-to-use pickup components for 2D scenes, demonstrating:

  • inventory grants
  • optional effect triggers
  • optional combined behaviour (Pickups integration)

These scripts are intentionally lightweight, readable, and easy to modify for your own game logic.


πŸ“¦ Components

Script Description
ItemPickup2D Adds an ItemDefinition to the colliding GameObject’s inventory, then destroys itself.
WorldItemToInventory2D Near-identical variant of ItemPickup2D (kept for legacy/demo separation).
UnifiedPickup2D With or without REV_PICKUPS_PRESENT, can run an effect, give items, or both.

πŸš€ Quickstart

  1. Create a pickup prefab or empty GameObject.
  2. Add ItemPickup2D or UnifiedPickup2D.
  3. Assign:
  4. ItemDefinition
  5. Quantity
  6. (Optional) effect (for UnifiedPickup2D)
  7. Add a 2D Collider and set isTrigger = true.
  8. Ensure the colliding GameObject itself has a CharacterInventory (and thus an InventoryOwnerHook).
  9. Ensure a SceneInventoryService and ItemDatabase exist in the scene.

When the owner enters the trigger:

  • Item is added (inventory modes)
  • Effect is executed (effect modes)
  • Pickup object is destroyed (when destroyOnTrigger == true)

βš™οΈ Behaviour Details

ItemPickup2D

The simplest case:

svc.GiveExact(other.gameObject, stack, container);
Destroy(gameObject);
  • Works only if the colliding GameObject itself owns the inventory
  • Uses implicit conversion from string β†’ ContainerId
  • Quantity is clamped by container rules (maxStack)

WorldItemToInventory2D

  • Behaviour is effectively identical to ItemPickup2D
  • Exists for legacy/demo clarity or alternate naming conventions
  • No delayed, manual, or queued behaviour

UnifiedPickup2D

Mode-dependent behaviour:

  1. EffectOnly
  2. Runs the configured effect (native or Pickups-based)

  3. InventoryOnly

  4. Adds the item to inventory

  5. Both

  6. Runs the effect first, then adds the item

Finally:

if (destroyOnTrigger)
    Destroy(gameObject);

Effect-first execution matters when effects modify or destroy the target.

Dependency Notes

  • If REV_PICKUPS_PRESENT is not defined:
  • Effect paths compile out
  • Inventory path still works

  • If REV_PICKUPS_PRESENT is defined:

  • PickupEffect assets and decorated chains are supported
  • Context-aware effects are routed through adapters

  • OnValidate ensures:

  • Container name is trimmed
  • Quantity is clamped to β‰₯ 1
  • A warning is logged if the collider is not a trigger

⚠️ Gotchas

  • Inventory owner must be the collider itself
    No parent/child lookup is performed β€” attach CharacterInventory to the same GameObject as the collider.

  • Requires SceneInventoryService + ItemDatabase
    Without them, pickups safely do nothing.

  • 2D only
    For 3D games, replace Collider2D / OnTriggerEnter2D with 3D equivalents.

  • Example code, not production systems
    Extend with animations, VFX, pooling, rarity shine, audio, etc. as needed.


  • Use β†’ item use & effect execution
  • Adapters β†’ Pickups integration and context-aware effects