Hello all, been trying to google the issue with little luck in this case. Additionally the search function does not seem to be working so I thought I would ask directly. I am attempting to add an adjustable “burst” mode (like a 3 round burst) with an adjustable cooldown after it to this script but dont know how or where to insert it, I am very new to programing so please be patient. Current script:
var Bullet : GameObject;
var activeUnit=false;
function Update (){
if (activeUnit==true){
if(Input.GetButton(“Fire3”)){
var bullet = Instantiate(Bullet, GameObject.Find(“1GunL”).transform.position, transform.rotation);
No no, sorry, I mean a burst mode like a 3 round burst. so essentially, fires a certain amount of rounds and then you are unable to fire again for a certain amount of time.
Also, since the button will ring true as long as it is pressed, once every 33milliseconds, you’ll want to adjust your code slightly to something like this…
If input . Getbutton( fire button 3)
If firing == true
Return
If firing == false
{
Firing = true
Invokerepeating(“fireGun”, 0.1, 1.0);
}
function fireGun()
{
BulletCount++;
If (BulletCount >= bulletLimit)
{
cancelInvoke(fireGun);
Yield WaitForSeconds2);
BulletCount = 0;
}
Fire gun stuff here
}
Firing = true;