IEnumerator InstateBullet() { GameObject go = Instantiate(bulletPrefab); go.transform.position = transform.position; ZhiXianPauseBullet pauseBullet = go.GetComponent <ZhiXianPauseBullet>(); pauseBullet.targetVec = go.transform.position - targetVec; pauseBullet.isRange = isRange; pauseBullet.pauseSpeed = Random.Range(2, 10); pauseBullet.injured = 30; pauseBullet.HP = 30; pauseBullet.m_Type = BulletTpye.emptyBullet; yield return(new WaitForSeconds(0.02f)); StartCoroutine(InstateBullet()); }
IEnumerator InstanteBullet() { for (int i = 0; i < 60; i++) { GameObject go = Instantiate(bulletPrefab); Vector3 pos = new Vector3(radius * Mathf.Cos(angle * Mathf.Deg2Rad) + centerPoint.x, radius * Mathf.Sin(angle * Mathf.Deg2Rad) + centerPoint.y); transform.position = new Vector3((radius - 0.1f) * Mathf.Cos(angle * Mathf.Deg2Rad) + centerPoint.x, (radius - 0.1f) * Mathf.Sin(angle * Mathf.Deg2Rad) + centerPoint.y); go.transform.position = pos; ZhiXianPauseBullet zhiXianBullet = go.GetComponent <ZhiXianPauseBullet>(); zhiXianBullet.targetVec = new Vector2(radius * Mathf.Cos((angle) * Mathf.Deg2Rad), radius * Mathf.Sin((angle) * Mathf.Deg2Rad)); angle += 6; zhiXianBullet.injured = 60; zhiXianBullet.HP = 90; zhiXianBullet.m_Type = BulletTpye.emptyBullet; SpriteRenderer render = go.GetComponent <SpriteRenderer>(); render.sprite = sprite; yield return(new WaitForSeconds(0.02f)); } StartCoroutine(InstanteBullet()); }