Quantcast
Viewing all articles
Browse latest Browse all 592

if-statement not executing?

Hello! The follow script is a modified version of another gun I made. The other gun works just perfect, but this gun script just won't let me reload. (NOTE: if-statement in the 'Reload' function!) #pragma strict public var canFire : boolean = true; public var ShootAble : boolean = true; public var Bullets : int = 10; public var Delay : float = 0.5f; public var rocketPrefab : Rigidbody; public var barrelEnd : Transform; public var Shoot : AudioSource; public var cocking : AudioSource; function Update () { if(ShootAble == true && canFire == true){ if(Input.GetMouseButton(0)) { var rocketInstance : Rigidbody; Shoot.Play(); rocketInstance = Instantiate(rocketPrefab, barrelEnd.position, barrelEnd.rotation); Bullets -= 1; Wait(); } } if(Bullets < 0){ canFire = false; Bullets = 0; if(canFire == false && Bullets == 0){ Reload(); } } } function Wait(){ ShootAble = false; yield WaitForSeconds(Delay); ShootAble = true; } function Reload(){ if(Input.GetKey(KeyCode.R)){ Bullets = 30; cocking.Play(); canFire = true; } } Help would be appreciated. With best regards.

Viewing all articles
Browse latest Browse all 592

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>