public GameObject[] SpawnBullets() { rotations = new float[GetSpawnData().numberOfBullets]; if (GetSpawnData().isRandom) { // This is in Update because we want a random rotation for each bullet each time RandomRotations(); } // Spawn Bullets GameObject[] spawnedBullets = new GameObject[GetSpawnData().numberOfBullets]; for (int i = 0; i < GetSpawnData().numberOfBullets; i++) { spawnedBullets[i] = BulletManager.GetBulletFromPool(); if (spawnedBullets[i] = null) { spawnedBullets[i] = Instantiate(GetSpawnData().bulletResource, transform); } else { spawnedBullets[i].transform.SetParent(transform); spawnedBullets[i].transform.localPosition = Vector2.zero; } var b = spawnedBullets[i].GetComponent <Bullet>(); b.rotation = rotations[i]; b.speed = GetSpawnData().bulletSpeed; b.velocity = GetSpawnData().bulletVelocity; if (GetSpawnData().isNotParent) { spawnedBullets[i].transform.SetParent(null); } } return(spawnedBullets); }