Working collisions on event-based triggers

This commit is contained in:
Michal Pikulski
2025-09-18 12:42:05 +02:00
parent 50070651c5
commit 44c1e48b82
12 changed files with 530 additions and 428 deletions

View File

@@ -60,8 +60,11 @@ namespace Minigames.DivingForPictures
[SerializeField] private int totalMaxPoolSize = 15;
[Header("Layer Settings")]
[Tooltip("Layer mask for tile collision detection - should match WorldObstacle layer")]
[SerializeField] private LayerMask tileLayerMask = 1 << 6; // WorldObstacle layer
[Tooltip("Layer mask for tile collision detection during spawn position validation")]
[SerializeField] private LayerMask tileLayerMask = -1; // Let user configure which layers to avoid
[Tooltip("Target layer for spawned obstacles - obstacles will be placed on this layer")]
[SerializeField] private int obstacleLayer = 11; // Default to layer 11, but configurable
[Header("Events")]
[Tooltip("Called when an obstacle is spawned")]
@@ -117,11 +120,11 @@ namespace Minigames.DivingForPictures
obstaclePrefabs[i].AddComponent<FloatingObstacle>();
}
// Ensure the prefab is on the correct layer
if (obstaclePrefabs[i].layer != 11) // QuarryObstacle layer
// Ensure the prefab is on the correct layer (using configurable obstacleLayer)
if (obstaclePrefabs[i].layer != obstacleLayer)
{
Debug.LogWarning($"Obstacle prefab {obstaclePrefabs[i].name} is not on QuarryObstacle layer (11). Setting layer automatically.");
SetLayerRecursively(obstaclePrefabs[i], 11);
Debug.LogWarning($"Obstacle prefab {obstaclePrefabs[i].name} is not on the configured obstacle layer ({obstacleLayer}). Setting layer automatically.");
SetLayerRecursively(obstaclePrefabs[i], obstacleLayer);
}
}
}