public void FireAround(BulletRef bulletIdx, Vector3 pos, float bulletSpeed = 3f, float angleRange = 360f) { float angle = 90 - angleRange * 0.5f; for (int i = 0; i < 6; ++i) { float x = Mathf.Cos(Mathf.Deg2Rad * angle); float y = Mathf.Sin(Mathf.Deg2Rad * angle); GameObject bullet = Instantiate(bulletPrefabs[(int)bulletIdx], pos, Quaternion.identity); bullet.GetComponent <BulletBehavior>().SetDirection(new Vector3(x, y, 0), bulletSpeed); angle += angleRange / 6; } }
public void FireAt(BulletRef bulletIdx, Vector3 pos, Vector3 dir, float bulletSpeed) { GameObject bullet = Instantiate(bulletPrefabs[(int)bulletIdx], pos, Quaternion.identity); bullet.GetComponent <BulletBehavior>().SetDirection(dir, bulletSpeed); }