IEnumerator SpawnExplosions(Transform other) { ScreenShaker.StartShakin(); Vector3 position = other.position; int count = Random.Range(3, 6); while (count > 0) { if (ExplosionPrefab) { var offset = 1.5f * Random.onUnitSphere; offset.y = 0; var obj = GameObject.Instantiate(ExplosionPrefab); obj.transform.position = position + 0.5f * Vector3.up + offset; Destroy(obj, 1.0f); } if (Audio) { Audio.PlayOneShot(CarSmash); } count--; yield return(new WaitForSeconds(0.1f)); } ScreenShaker.StopShakin(); }