✨ 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:
ScriptableObjecteffects integrate with the Inventory systemItemDefinition.useEffects[]drives runtime behaviourIUseEffectis resolved and executed byItemUseSystem
📦 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¶
- Create or open an
ItemDefinition - Enable usage:
itemDef.usable = true;
itemDef.useEffects = new ScriptableObject[]
{
debugPingEffect,
spawnVfxEffect
};
When triggered via ItemUseSystem, each effect will be:
- Resolved to
IUseEffect - Executed in order
- 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
IDamageablemay be null, depending on the target and effect settingsUseEffectObjectis 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.
📎 Related¶
- Inventory Use System → handles effect execution
ItemDefinition.useEffects[]→ effect assignment- Inventory Teachables → real usage examples