CAMERA_FIXES_SUMMARY.md 3.1 KB

Camera Issues Fixed

Issues Addressed

Issue 1: Camera doesn't focus on TeamMarker GameObject

Problem: Team marker centering was changing zoom level instead of preserving it. Fix: Modified CenterOnTeamMarker() to preserve current zoom level:

// Before: targetZoom = focusZoomLevel;
// After: targetZoom = cam.orthographicSize; // Keep current zoom

Added: Better error handling with fallback to find team marker by name if normal method fails.

Issue 2: Full map view makes camera move around so nothing is visible

Problem: Full map positioning wasn't accounting for tile scaling. Fix: Updated ZoomToFullMap() to properly use MapVisualizer.tileSize:

// Before: Simple map dimensions without scaling
targetPosition = new Vector3(mapData.Width / 2f, y, mapData.Height / 2f);

// After: Proper world coordinates with tile scaling
targetPosition = new Vector3(
    (mapData.Width * tileSize) / 2f,
    transform.position.y,
    (mapData.Height * tileSize) / 2f
);

Issue 3: Max zoom still limited to 80 with scroll wheel

Problem: MapVisualizer.PositionCameraToMap() was overriding camera zoom settings. Fix: Modified MapVisualizer to preserve user's zoom level:

// Before: Always set camera size
mainCam.orthographicSize = Mathf.Max(requiredHeight, requiredWidth, 80f) + 20f;

// After: Only adjust if camera zoom is too small
if (mainCam.orthographicSize < suggestedSize) {
    mainCam.orthographicSize = suggestedSize;
}

Added: Debug logging to track zoom limit behavior.

Issue 4: Zoom level changes when centering team marker

Problem: Centering was forcing a specific zoom level. Fix: Changed to preserve current camera zoom level when centering on team marker.

Additional Improvements

🔧 Enhanced Error Handling

  • Better debugging messages for team marker issues
  • Fallback mechanism to find team marker by name
  • Clear instructions for user (press R to place team)

🔧 Improved Help System

  • Updated help text to show actual zoom range
  • Added mention of team placement controls
  • Clarified that centering preserves zoom

🔧 Better Coordinate Handling

  • Proper tile size scaling for world coordinates
  • Accurate map center calculation
  • Respect for exploration system coordinate transformations

How to Test

  1. Team Marker Centering:

    • Place team marker (press R if needed)
    • Set any zoom level you like
    • Press C - camera should center on team marker WITHOUT changing zoom
  2. Full Map View:

    • Press F - camera should smoothly move to show entire map
    • Map should be properly centered and visible
  3. Enhanced Zoom Range:

    • Use mouse wheel - should now zoom out to maxZoom (200) instead of being stuck at 80
    • Zoom range should be 2-200 as configured
  4. Preserved Settings:

    • Manual camera movement should stop automatic movement
    • User zoom settings should be preserved across map regeneration

All fixes are in the MMCameraController.cs and MapVisualizer.cs files. The camera system should now work smoothly without the reported issues.