// Start is called before the first frame update IEnumerator Start() { while (true) { Values.BalloonTypes balloonType = Values.BalloonTypes.Normal; SpawnBalloon(balloonType); yield return(new WaitForSeconds(Random.Range(m_SpawnIntervalMin, m_SpawnIntervalMax))); } }
public void SpawnBalloon(Values.BalloonTypes balloonType) { int index = (int)balloonType; Vector3 spawnVector = new Vector3(Random.Range(-m_XBounds, m_XBounds), m_StartY, 0.0f); Balloon balloon = Instantiate(m_Prefabs[index].ballon, spawnVector, Quaternion.identity); balloon.rb.angularVelocity = Random.Range(-m_MaxAngularVelocity, m_MaxAngularVelocity); balloon.trans.localScale = Vector2.one * Random.Range(balloon.scaleMin, balloon.scaleMax); balloon.transform.parent = transform; }