COMBAT_EVENT_ASSET_REFERENCE_FIX.md 2.9 KB

Fix: Combat Event Using Asset References Instead of Strings

Problem

The combat event inspector is still showing "Possible Enemy Types" (string input) instead of "Possible Enemies" (asset drag-drop).

Quick Fix Steps

Step 1: Use the Fixer Tool

  1. Go to RPG → Utilities → Fix Combat Events
  2. Click "Force Reimport TravelEventTypes.cs"
  3. Click "Refresh Asset Database"

Step 2: Create New Combat Event (Clean Slate)

  1. Delete any existing combat event assets that show string inputs
  2. Right-click in Project → Create → RPG → Travel Events → Combat Event
  3. Name it SkeletonAmbush

Step 3: Configure with Asset References

Open the SkeletonAmbush asset and you should now see:

✅ Correct Inspector Layout:

Combat Event Settings
├─ Min Enemies: 1
├─ Max Enemies: 3
└─ Possible Enemies: [Drag assets here] 
   ├─ Size: 1
   └─ Element 0: [Drag SkeletonWarrior.asset here]

Backward Compatibility  
└─ Possible Enemy Types: (empty - ignore this)

❌ Wrong Inspector Layout:

Combat Event Settings
├─ Min Enemies: 1
├─ Max Enemies: 3
└─ Possible Enemy Types: [Text input] ← WRONG!

Step 4: Drag Your Enemy Assets

  1. Expand "Possible Enemies" section
  2. Set Size to 1 (or however many enemy types you want)
  3. Drag SkeletonWarrior.asset from Project window into Element 0
  4. The field should show the asset icon and name

Step 5: Verify It's Working

✅ Field shows: SkeletonWarrior (EnemyCharacterData)
❌ Field shows: "Skeleton Warrior" (string)

Alternative: Right-Click Fix

If you already have a combat event asset:

  1. Right-click the asset in Project window
  2. Select RPG → Fix Combat Event Inspector
  3. Refresh the Inspector by clicking elsewhere and back

Create Skeleton Ambush Example

Complete Configuration:

Event Name: Skeleton Ambush
Event Description: Ancient skeletal warriors rise to attack!
Event Type: Combat
Rarity: Common

# Terrain (where skeletons appear)
Forest Chance: 0.8
Mountain Chance: 0.6  
Road Chance: 0.2
Town Chance: 0.1

# Combat Settings
Min Enemies: 1
Max Enemies: 3
Possible Enemies:
  - SkeletonWarrior.asset  ← Drag this asset here!

# Descriptions
Encounter Descriptions:
  - "Bones clatter as skeletal warriors emerge from the earth!"
  - "Ancient skeletons wielding rusty weapons block your path!"

Why This Happens

  • Unity Inspector Caching: Unity sometimes caches old inspector layouts
  • Script Compilation: Changes to class fields require Unity to recompile
  • Asset Serialization: Old assets may still have old field data

Verification

After fixing, you should see:

  • 🎯 Drag-drop asset fields instead of text input
  • 🔗 Direct references to your enemy data assets
  • Type safety - no more typos possible
  • 🎮 Full enemy data access in battle setup

The new system is much safer and more powerful! 🎯