Resolved the obstacle spawning issue

This commit is contained in:
Michal Pikulski
2025-09-18 15:51:18 +02:00
parent c5ce2ae1af
commit 9be8d1619b
4 changed files with 185 additions and 56 deletions

View File

@@ -21,6 +21,7 @@ namespace Minigames.DivingForPictures
FloatingObstacle obstacleComponent = obstacle.GetComponent<FloatingObstacle>();
if (obstacleComponent != null)
{
Debug.Log($"[ObstaclePool] Returning obstacle {obstacle.name} to pool");
Return(obstacleComponent, prefabIndex);
}
else
@@ -37,7 +38,16 @@ namespace Minigames.DivingForPictures
/// <returns>An obstacle instance ready to use</returns>
public GameObject GetObstacle(int prefabIndex)
{
Debug.Log($"[ObstaclePool] GetObstacle called for prefab index {prefabIndex}");
FloatingObstacle obstacleComponent = Get(prefabIndex);
if (obstacleComponent == null)
{
Debug.LogError($"[ObstaclePool] Get() returned null for prefab index {prefabIndex}");
return null;
}
Debug.Log($"[ObstaclePool] Get() returned obstacle {obstacleComponent.name}, active state: {obstacleComponent.gameObject.activeInHierarchy}");
return obstacleComponent.gameObject;
}
}