As you can see from the image the laser does not shoot at a consistent rate.
I have this in my update:
if(Input.GetKeyDown(KeyCode.Space)){
InvokeRepeating("fireLaser",0.0001f,1f / fireLaserRate);
}
if(Input.GetKeyUp(KeyCode.Space)){
CancelInvoke("fireLaser");
}
And this in the method called to fire:
void fireLaser(){
Vector3 playerLaserStartPos = transform.position + new Vector3(0,playerLaserStartPosY,0);
GameObject laser = Instantiate(playerLaser,playerLaserStartPos,Quaternion.identity);
laser.GetComponent<Rigidbody2D>().velocity = new Vector3(0,laserSpeed,transform.position.z);
}
