Skip to content

✨ Sample Effects

Demo IUseEffect implementations provided as simple ScriptableObject assets.

Used by the Inventory system (via ItemUseSystem) to trigger behaviour when an item is used.

🧩 These are examples only — safe to delete or replace 💡 They exist to show the expected integration pattern, not to be production systems


🎯 Purpose

Provide minimal, working examples of authorable item-use effects.

These demonstrate how:

  • ScriptableObject effects integrate with the Inventory system
  • ItemDefinition.useEffects[] drives runtime behaviour
  • IUseEffect is resolved and executed by ItemUseSystem

📦 Contents

File Description
UseEffectObject Sample base class implementing IUseEffect
DebugPingEffect Logs a message when the item is used
SpawnVfxEffect Spawns a VFX prefab at the target for a short time

🚀 Usage

  1. Create or open an ItemDefinition
  2. Enable usage:

itemDef.usable = true;
3. Assign one or more effects:

itemDef.useEffects = new ScriptableObject[]
{
    debugPingEffect,
    spawnVfxEffect
};

When triggered via ItemUseSystem, each effect will be:

  1. Resolved to IUseEffect
  2. Executed in order
  3. Applied to the resolved target context

⚠️ Important Notes

  • Effects are executed only if they resolve successfully
  • At least one effect must apply for the item to be consumed
  • IDamageable may be null, depending on the target and effect settings
  • UseEffectObject is not required — it’s just a convenience base

👉 The only requirement is:

public class MyEffect : ScriptableObject, IUseEffect

⚙️ Extend It

Create your own effect by implementing IUseEffect (optionally via UseEffectObject):

public class HealEffect : UseEffectObject
{
    public int healAmount = 25;

    public override void Apply(IDamageable dmg, GameObject target)
    {
        if (dmg != null)
            dmg.Heal(healAmount);
    }
}

🧠 Design Notes (Why this exists)

These samples intentionally:

  • Avoid internal APIs
  • Avoid reflection
  • Use only public, supported seams
  • Mirror how real gameplay code should interact with Inventory

If these examples work — your integration is correct.


  • Inventory Use System → handles effect execution
  • ItemDefinition.useEffects[] → effect assignment
  • Inventory Teachables → real usage examples