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); } }