- Home /
shot delay in between bullets
How do I make a delay time or a very short period of time where the player can't shoot so you can't fire the gun as fast as you want. Here is what part of my script looks like:
if(Input.GetButtonDown("Fire1")){
if(canshoot == 1){
var bulletCreateS = Instantiate(spasbullet, GameObject.Find ("bulletspawn").transform.position, Quaternion.identity);
Physics.IgnoreCollision(bulletCreateS.collider, Player.collider);
bulletCreateS.tag = "SMbullet";
bulletCreateS.rigidbody.AddForce(transform.forward * spbulletspeed);
AmmoMainGun.ammo -= 1;
shot = true;
}
}
//Please use the 10101 button above to make your code look good. Thanks =).
Comment
Best Answer
Answer by Justin Warner · Mar 28, 2011 at 01:35 AM
http://unity3d.com/support/documentation/ScriptReference/index.Coroutines_26_Yield.html
Check that out... You can make a method that yields with a WaitForSeconds, I do believe it accepts half seconds too, so you can make it more of a machine gun than shotgun... Hope this helps =). Also, I edited, but next time you post, please try to highlight all your code and push the 10101 button =). I know it's your first time, so I'm not being a dick haha. Thanks and good luck!