Settlement Interaction Debugging and Setup Guide
Problem
Settlement interaction UI shows but E key doesn't work to enter settlements.
Quick Diagnosis
Step 1: Add the Debugger
- Add
SettlementInteractionDebugger.cs component to any GameObject in MapScene2
- Run the scene and check the console output
- The debugger will show exactly what's missing
Step 2: Common Issues and Solutions
Issue A: No SettlementInteractionManager in Scene
Symptoms: Debugger shows "❌ SettlementInteractionManager NOT FOUND!"
Solution:
- Create empty GameObject in MapScene2 named "SettlementInteractionManager"
- Add
SettlementInteractionManager component to it
- Configure settings:
- Team Marker: Will auto-find "TeamMarker"
- Interaction Distance: 2.0
- Enter Settlement Key: E
- Town Scene Name: "TownSceen"
- Enable Debug Logs: true
Issue B: Missing UI Setup
Symptoms: Logic works but no UI shows
Solution:
- Create GameObject named "SettlementInteractionUI"
- Add
UIDocument component
- Add
SettlementInteractionUI component
- Set UI Document asset to
SettlementInteractionUI.uxml
- Make sure UXML file exists in
Assets/Resources/UI/MapScene/
Issue C: TeamMarker Not Found
Symptoms: Debugger shows "❌ TeamMarker GameObject not found!"
Solution:
- Make sure GameObject named "TeamMarker" exists in scene
- Or manually assign teamMarker reference in SettlementInteractionManager
Issue D: MapData Not Available
Symptoms: "Settlements count: 0" or MapData null
Solution:
- Ensure MapMaker2 component exists in scene
- Ensure map has been generated with settlements
- Check that MapData.GetAllSettlements() returns settlements
Issue E: Input System Issues
Symptoms: Manual entry works but E key doesn't
Solution:
- Check if project uses new Input System (Package Manager)
- If using new Input System, might need to update input handling
- Test with debugger's "Test Input Detection" to see if keys register
Step 3: Testing Process
- Add Debugger: Put SettlementInteractionDebugger on any GameObject
- Run Scene: Check console for component diagnosis
- Move TeamMarker: Move near settlements and watch debug output
- Test Keys: Press F1 to test detection, F2 to test manual entry
- Check Console: Look for debug messages when moving near settlements
Step 4: Verification
When working correctly, you should see:
- ✅ All components found in diagnosis
- Debug messages when moving TeamMarker near settlements
- UI prompt appears/disappears based on proximity
- E key successfully loads town scene
- Settlement context properly configured
Quick Fix Commands
Force Enable All Debug Logging
// In Unity Console or attached to a button
var manager = FindFirstObjectByType<SettlementInteractionManager>();
if (manager != null) manager.enableDebugLogs = true;
Manual Settlement Entry Test
// Test if the logic works without input
var manager = FindFirstObjectByType<SettlementInteractionManager>();
if (manager != null) manager.TestEnterCurrentSettlement();
Check Current Settlement Detection
// See if any settlement is currently detected
var manager = FindFirstObjectByType<SettlementInteractionManager>();
var settlement = manager?.GetCurrentNearbySettlement();
Debug.Log($"Current settlement: {settlement?.name ?? "None"}");
Debug UI Overlay
The SettlementInteractionDebugger provides an on-screen debug panel that shows:
- Current settlement detection status
- TeamMarker position
- Quick test buttons
- Real-time component status
Toggle with enableDebugOverlay = true in the debugger component.
Expected Debug Output
When working correctly, moving TeamMarker near a settlement should show:
[SettlementInteraction] Near settlement: Riverside Town (Town)
[SettlementInteraction] SettlementContext configured: Riverside Town (Town) - Harbor: true
[SettlementInteraction] Loading town scene: TownSceen
When the E key is pressed near a settlement:
[SettlementInteraction] Entering settlement: Riverside Town (Town)