# How do I fire multiple bullets in an arc?

I have a variable `projectileNum` and when it is set to one, it works perfectly, but when it is above that, nothing I do gets it to work. If I use a for or while loop, it fires multiple bullets, but they are stacked on top of each other. I want the bullets to spread out in a fan. They will start from a certain point, and fire out at an angle. I need this to work for all integers. If there is a way to do it without using a bunch of if statements, that would be preferred. `projectileNum` is a float from 1-6, but will always be an integer by design. If you need more information, let me know.

edit: I need it fired based on how many bullets there are. This is my firing code:

`void Shoot() { for (int i = 0; i < projectileNumber; i++) { GameObject b = Instantiate(bullet, firepoint.position, firepoint.rotation); b.transform.localScale = new Vector3(projectileSize / 5f, projectileSize / 5f, 0f); Rigidbody2D rb = b.GetComponent<Rigidbody2D>(); rb.AddForce(firepoint.up * projectileSpeed * 6, ForceMode2D.Impulse); GameObject.Destroy(b, range); } } `

really depends on how you are moving your bullets, you should really include your code so people can help you, but if you are moving your bullets based on the it’s transform.forward, then all you have to do is rotate the bullet and it will go out in a different direction.

Ok, I figured it out. I had to scrap the `rb.AddForce(firepoint.up * projectileSpeed * 6, ForceMode2D.Impulse);` , unfortunately, so now I have a script for the bullets:

`using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Bullet : MonoBehaviour
{
float obj;

``````void Start()
{
obj = GameObject.FindGameObjectWithTag("Player").GetComponent<Player>().projectileSpeed;
}

void Update()
{
transform.Translate(0f, obj / 10, 0f);
}
``````

}
`

This is what my firing code now looks like:

`void Shoot()
{
if (projectileNumber <= 0f)
{
projectileNumber = 1f;
}
float vectZ;
float angle = Mathf.Max(5f, (11f - Mathf.Pow(1.05f, projectileNumber - 2f)));
if (projectileNumber % 2 == 0)
{
vectZ = ((projectileNumber / 2) * 10) - 5;
for (int i = 0; i < projectileNumber; i++)
{
CreateBullet(new Vector3(0f, 0f, vectZ));
vectZ -= 10f;
}
}
else
{
vectZ = ((projectileNumber - 1) / 2) * 10;
for (int i = 0; i < projectileNumber; i++)
{
CreateBullet(new Vector3(0f, 0f, vectZ));
vectZ -= 10f;
}
}
}

``````void CreateBullet(Vector3 offsetRotation)
{
GameObject b = Instantiate(bullet, firepoint.position, firepoint.rotation);
b.transform.localScale = new Vector3(projectileSize / 5f, projectileSize / 5f, 0f);
b.transform.Rotate(offsetRotation);
GameObject.Destroy(b, range);
}
``````

`

If you’re curious as to how I am firing, this is the code for that.

`void RefreshInvoke() { CancelInvoke("Shoot"); lastfireRate = fireRate; InvokeRepeating("Shoot", 1 / fireRate, 1 / fireRate); } `
`void FixedUpdate() { if (fireRate != lastfireRate) { RefreshInvoke(); } } `