I’m working on creating bullets for a remake of diep.io, but am new to arrays. I received an error that said nullPointerExeption, and looked it up to find out what I did wrong, but found that it means my array hasn’t been defined. I’ve double checked that I’m running the code, and I define the array’s at the beginning of my code.
// at the beginning
float[] arrayBulletAngle;
float[] arrayBulletTotalDistance;
float[] arrayBulletHealth;
float[] arrayBulletSpeed;
int numberOfPlayerBullets = 1;
// I call this in the draw loop
void createBullet(float angle){
numberOfPlayerBullets ++;
arrayBulletAngle[numberOfPlayerBullets] = angle;
arrayBulletTotalDistance[numberOfPlayerBullets] = 0;
arrayBulletHealth[numberOfPlayerBullets] = bulletHealth;
arrayBulletSpeed[numberOfPlayerBullets] = angle;
}