At the moment Ive got this script working that counts down the ammo by one when the LMB has been clicked once, this is for a semi automatic sort of gun. Know I’m trying to change it so it counts down when the LMB is being held, I have tried over and over but I keep getting tons of errors, can anyone help me out?
This is my semi auto script,
var fullClip : int = 8;
var bulletsLeft : int = 8;
var reloadTime = 1.5;
var myFont:Font;
var someInt : int = 20;
function Update () {
if(Input.GetButtonDown("Fire1")){
if(bulletsLeft > 0 ){
bulletsLeft -- ;
}
}
if(Input.GetButtonDown("r")){
Reload();
}
}
function Reload () {
yield WaitForSeconds(reloadTime);
bulletsLeft = fullClip ;
}
function OnGUI() {
GUI.Label (Rect (25, 20, 100, 20), ""+bulletsLeft);
GUI.skin.label.font = myFont;
GUI.skin.label.fontSize = someInt;
}
This question was hard to answer because you mentioned GUI, so I thought you meant a GUI.Button.
Instead of Input.GetButtonDown(“Fire1”), you should use Input.GetButton(“Fire1”). That will return true as long as the button is held, instead of just the frame it’s pressed.