void InitializeObstacles() { obstaclesPool = new ObjectPooler(obstaclePrefab, 10); for (int i = 0; i < 10; i++) { obstaclesPool.Spawn(levelPlanner.GenerateNextObstaclePosition(), Quaternion.identity); } }
public void OnBecameInvisible() { if (gameObject.activeInHierarchy == true) { poolMember.Despawn(); nextObstaclePosition = levelPlanner.GenerateNextObstaclePosition(); poolMember.myPool.Spawn(nextObstaclePosition, Quaternion.identity); } }