I'm making a 2D shooter and wanted to know how to fire a curtain of bullets like in a bullet hell game from a single object. I'm trying to figure out how to alter a normal firing code to spread out in a fan shaped or random pattern if possible.
Edit: Code for firing //Fire rate of shots(Every # seconds, fire 1 shot) var fireRate: float =1.0; //Time to start shooting private var nextFire: float = 0.0;
If you are using particles for bullets you can use the random velocity setting.
If you are using rigid bodies for bullets you can use Random.insideUnitSphere to get a random direction for it to travel in.
If you wanted the bullets to move in a pattern then you can set the angle using some kind of math equation. Even very simple equations can result in interesting looking patterns. e.g. if you increment the y-rotation of the bullet fired by 10 degrees every frame they'll fan out like a spiral. If you then have a second set of bullets with their y-rotation incrementing in the opposite direction you'll get a double spiral that crosses over each other.
Changed rigid body to game object.