|
|
@@ -12,7 +12,8 @@ public class MMCameraController : MonoBehaviour
|
|
|
public KeyCode centerOnTeamKey = KeyCode.C;
|
|
|
public KeyCode zoomToFullMapKey = KeyCode.F;
|
|
|
public float focusZoomLevel = 10f;
|
|
|
- public float centeringSpeed = 2f;
|
|
|
+ public float centeringSpeed = 5f; // Increased for faster centering
|
|
|
+ public float teamMarkerZoomSize = 100f; // Zoom level when centering on team marker
|
|
|
|
|
|
private Camera cam;
|
|
|
private Vector3 lastMousePosition;
|
|
|
@@ -89,11 +90,14 @@ public class MMCameraController : MonoBehaviour
|
|
|
transform.position = Vector3.Lerp(transform.position, targetPosition, Time.deltaTime * centeringSpeed);
|
|
|
cam.orthographicSize = Mathf.Lerp(cam.orthographicSize, targetZoom, Time.deltaTime * centeringSpeed);
|
|
|
|
|
|
- // Check if we're close enough to stop moving
|
|
|
- if (Vector3.Distance(transform.position, targetPosition) < 0.1f &&
|
|
|
- Mathf.Abs(cam.orthographicSize - targetZoom) < 0.1f)
|
|
|
+ // Check if we're close enough to stop moving (more lenient thresholds for faster completion)
|
|
|
+ if (Vector3.Distance(transform.position, targetPosition) < 0.5f &&
|
|
|
+ Mathf.Abs(cam.orthographicSize - targetZoom) < 0.5f)
|
|
|
{
|
|
|
isMovingToTarget = false;
|
|
|
+ // Snap to final position to avoid endless lerping
|
|
|
+ transform.position = targetPosition;
|
|
|
+ cam.orthographicSize = targetZoom;
|
|
|
}
|
|
|
}
|
|
|
else
|
|
|
@@ -108,7 +112,7 @@ public class MMCameraController : MonoBehaviour
|
|
|
if (Input.GetKeyDown(KeyCode.H))
|
|
|
{
|
|
|
Debug.Log("💡 Camera Controls:\n" +
|
|
|
- $"- {centerOnTeamKey}: Center on team marker (preserves zoom)\n" +
|
|
|
+ $"- {centerOnTeamKey}: Center on team marker (zoom to {teamMarkerZoomSize})\n" +
|
|
|
$"- {zoomToFullMapKey}: Zoom to full map\n" +
|
|
|
"- WASD/Arrows: Move camera\n" +
|
|
|
$"- Mouse wheel: Zoom (range: {minZoom}-{maxZoom})\n" +
|
|
|
@@ -138,11 +142,9 @@ public class MMCameraController : MonoBehaviour
|
|
|
// Set target position to center on team marker (keep Y position for camera height)
|
|
|
// For top-down view: X and Z are the map coordinates, Y is camera height
|
|
|
targetPosition = new Vector3(teamPos.x, transform.position.y, teamPos.z);
|
|
|
- // Keep current zoom level instead of changing to focusZoomLevel
|
|
|
- targetZoom = cam.orthographicSize;
|
|
|
+ // Use specific zoom level for team marker focus
|
|
|
+ targetZoom = teamMarkerZoomSize;
|
|
|
isMovingToTarget = true;
|
|
|
-
|
|
|
- Debug.Log($"🎯 Centering camera on team marker at position: {teamPos}");
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
@@ -154,7 +156,7 @@ public class MMCameraController : MonoBehaviour
|
|
|
{
|
|
|
Vector3 teamPos = foundMarker.transform.position;
|
|
|
targetPosition = new Vector3(teamPos.x, transform.position.y, teamPos.z);
|
|
|
- targetZoom = cam.orthographicSize;
|
|
|
+ targetZoom = teamMarkerZoomSize;
|
|
|
isMovingToTarget = true;
|
|
|
Debug.Log($"🎯 Found team marker by name, centering at: {teamPos}");
|
|
|
}
|
|
|
@@ -215,6 +217,14 @@ public class MMCameraController : MonoBehaviour
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ /// <summary>
|
|
|
+ /// Automatically center and zoom to team marker when it's created
|
|
|
+ /// </summary>
|
|
|
+ public void OnTeamMarkerCreated()
|
|
|
+ {
|
|
|
+ CenterOnTeamMarker();
|
|
|
+ }
|
|
|
+
|
|
|
private void HandleMovement()
|
|
|
{
|
|
|
float horizontal = Input.GetAxis("Horizontal");
|