Combat Event Popup Setup Guide
Overview
The combat event popup system has been enhanced to support two setup methods. The popup now includes comprehensive debugging to help identify any setup issues.
Setup Options
Option 1: Direct Component Setup (Recommended for Testing)
- Find your TravelEventSystem GameObject in the scene
- Add the CombatEventIntegration component to it
- Add the CombatEventPopup component to the same GameObject
- The system will automatically detect and connect the components
Option 2: Prefab-Based Setup (Production Ready)
- Create a prefab containing the CombatEventPopup component
- Add CombatEventIntegration to your TravelEventSystem GameObject
- Assign your popup prefab to the Combat Popup Prefab field
- The system will instantiate the popup when needed
Verification Steps
1. Check Console for Initialization Messages
When the scene starts, you should see:
🔧 Combat Event Integration starting...
📦 Instantiating combat popup from prefab... (if using prefab)
✅ Combat Event Integration initialized successfully
2. Test Combat Event Triggering
When a combat event occurs, you should see debug messages like:
🔍 Attempting to find CombatEventIntegration component...
🎯 Found CombatEventIntegration via FindObjectsByType
📞 Calling ShowCombatChoicePopup method...
🎭 Showing combat choice popup: A group of bandits blocks your path!
3. Verify Component Attachment
In the Inspector, ensure:
- TravelEventSystem GameObject has CombatEventIntegration component
- CombatEventIntegration component has either:
- Combat Event Popup field assigned (Option 1), OR
- Combat Popup Prefab field assigned (Option 2)
Troubleshooting
No Popup Appears
- Check Console: Look for initialization error messages
- Verify Components: Ensure CombatEventIntegration is on TravelEventSystem GameObject
- Check References: Ensure either popup component or prefab is assigned
- Test in Play Mode: The system only works when the scene is playing
Error Messages
❌ Combat Event Integration requires TravelEventSystem on the same GameObject!
- Solution: Add CombatEventIntegration to the same GameObject as TravelEventSystem
❌ Combat popup prefab does not contain CombatEventPopup component!
- Solution: Ensure your prefab has the CombatEventPopup component
❌ Combat Event Integration requires a CombatEventPopup component or prefab!
- Solution: Either add CombatEventPopup component to scene or assign a prefab
Component Not Found During Events
If you see ⚠️ CombatEventIntegration component not found via FindObjectsByType:
- Ensure CombatEventIntegration is actually added to a GameObject in the scene
- Check that the GameObject is active
- Verify the component is enabled
Testing the System
Manual Test Steps
- Start the game in Play mode
- Initiate travel between locations
- If combat events don't trigger naturally, you can:
- Modify travel event probabilities in the Inspector
- Add multiple enemy types to locations
- Test with shorter travel distances
Debug Information
The system now provides extensive debugging:
- Component discovery process
- Method invocation attempts
- Popup display calls
- Event handling flow
Quick Setup Checklist
Recent Enhancements
- Flexible Setup: Support for both direct component and prefab-based setup
- Enhanced Debugging: Comprehensive logging throughout the integration process
- Better Error Handling: Clear error messages with solutions
- Automatic Detection: System automatically finds and connects components when possible