IEnumerator BoxSpawning(DataForBoxSpawning dataForBoxSpawning)
{
GameObject box = Instantiate(dataForBoxSpawning.TEST_BoxPrefab, dataForBoxSpawning.TEST_BoxSpawnPos.position, dataForBoxSpawning.TEST_BoxSpawnPos.rotation, null);
currentBox = box;
if (box == null)
{
Debug.LogError("Box prefab oluşturulamadı! Box null döndü.");
yield break;
}
Rigidbody rb = box.GetComponent<Rigidbody>();
Box b = box.transform.Find("Box")?.GetComponent<Box>();
if (b == null)
{
Debug.LogError("Box bileşeni bulunamadı!");
yield break;
}
rb.useGravity = false;
rb.isKinematic = true; // Box donduruldu
var senderType = BoxSenderTypeRandomiser(gameHandler.Day);
b.boxSenderType = senderType;
if (senderType == null)
{
Debug.LogError("BoxSenderTypeRandomiser null döndürdü!");
yield break;
}
var contentType = BoxContentTypeRandomiser(gameHandler.Day, senderType);
b.boxContentType = contentType;
if (contentType == null)
{
Debug.LogError("BoxContentTypeRandomiser null döndürdü!");
yield break;
}
SpawningContentListRandomizer(contentType, dataForBoxSpawning);
StopCoroutine(BoxSpawning(dataForBoxSpawning));
}
I Dont Understand Why It Freezes 1 out of 10 runs, i am about to lose my mind