Working monster spawns

This commit is contained in:
2025-09-19 13:46:24 +02:00
parent 40c3867d29
commit 2ec5c3d855
4 changed files with 393 additions and 135 deletions

View File

@@ -61,13 +61,19 @@ namespace Minigames.DivingForPictures
if (mainCamera == null)
return false;
Vector3 viewportPoint = mainCamera.WorldToViewportPoint(transform.position);
float buffer = 0.2f; // Extra buffer outside the screen
// Get the world position (will account for parent movement)
Vector3 worldPosition = transform.position;
Vector3 viewportPoint = mainCamera.WorldToViewportPoint(worldPosition);
return viewportPoint.x > -buffer &&
viewportPoint.x < 1 + buffer &&
viewportPoint.y > -buffer &&
viewportPoint.y < 1 + buffer;
// Adjust buffer to be larger below the screen to account for downward movement
float bufferSides = 0.2f;
float bufferTop = 0.2f;
float bufferBottom = 0.5f; // Larger buffer below the screen
return viewportPoint.x > -bufferSides &&
viewportPoint.x < 1 + bufferSides &&
viewportPoint.y > -bufferBottom &&
viewportPoint.y < 1 + bufferTop;
}
private void OnTriggerEnter2D(Collider2D other)