Hi guys
I’m pretty new to Unity and coding. I am trying to create a gun script for a gun, though I cannot seem to get the burst fire to work. I want it to shot three bullets in a burst when holding the mouse button down. When three bullets have been fired, the user must release the button and press again. Any ideas on what I am doing wrong?
I can give you the full gun script if you need it.
function FireBurst(){
ammoText.text="Ammo: "+ammo;
if(shoot==true){
if(Input.GetMouseButton(0) && Time.time > nextFire) {
while(burstCount!=3){
burstCount=burstCount +1;
BulletSpawn.light.intensity=1;
nextFire=Time.time+fireRate;
Instantiate(Bullet,BulletSpawn.transform.position,BulletSpawn.transform.rotation);
BulletSpawn.audio.Play();
ammo = ammo -1;
if(ammo <=30){
ammoText.color=Color.green;
}
if(ammo <=20){
ammoText.color=Color.yellow;
}
if(ammo <=10){
ammoText.color=Color.red;
}
if(Input.GetMouseButton(1)){
} else {
animation.Play("GunRecoil");
}
}
}
}
}