So i’m trying to create basically a Bullet Hell game from scratch. So i’m making my code which will allow me to make multiple bullet emitters, then spread them out equally automatically along however wide I want the emitters to spray their shots. However whenever I iterate my array on my for loop, I get a Null Reference Exception.
public int numberOfEmitters = 5;
public int emitterWidth = 30; //size of the angle (degrees)
private int[] emitterDir; //Array
void Start(){
for(int i = -1; i < numberOfEmitters; i++){
if (i > -1){
//Debug.Log ("Emitters #: " + i + " : Angle : " + (((emitterWidth * 2)/numberOfEmitters * (i + 1)) - emitterWidth));
emitterDir[(i + 1)] = (((emitterWidth * 2)/numberOfEmitters * (i + 1)) - emitterWidth);
}
else{
emitterDir[(i + 1)] = -emitterWidth;
}
}
}
So am I doing something wrong? Do I need to change my equation?