Hello, this is my first post so sorry if I don’t do it right , but anyway, I had a question how i could change this shooting script to make it were instead of clicking multiple times to shoot I could just hold down the left click button and rapid fire? Here is the Script…
public var bulletPrefab : Transform;
public var bulletSpeed : float = 6000;
var ammo : int = 60;
var gunShot : AudioClip;
var reload : AudioClip;
var emptyClip : boolean = false;
function Update () {
if(Input.GetButtonDown(“Fire1”)) {
if(ammo > 0) {
Shoot();
}
else{
return;
}
}
if(Input.GetKeyDown(KeyCode.R)) {
if(emptyClip) {
Reload();
}
}
if(ammo >= 0) {
emptyClip = true;
}
else {
emptyClip = false;
}
}
function Shoot(){
var bullet = Instantiate(bulletPrefab, transform.Find(“BulletSpawn”).position, transform.Find(“BulletSpawn”).rotation);
bullet.rigidbody.AddForce(transform.forward * bulletSpeed);
audio.PlayOneShot(gunShot);
ammo–;
}
function Reload() {
audio.PlayOneShot(reload);
ammo = 60;
}
function OnGUI() {
GUI.Label(Rect ( 0,0, 75, 25), "Ammo " + ammo);
}
Thanks! Bye.