Quantcast
Channel: Questions in topic: "error"
Viewing all articles
Browse latest Browse all 7934

im having trouble with raycast shooting script

$
0
0
well its in the description. i am getting some errors and i cant figure out what is going on. here is the script, and thanks in advance var Bullets : int; var CanShoot : boolean; var TheDamage = 10; var reloadTime = 5; var totalAmmo = 60; var reloadAmount = 30; function Update () if (totalAmmo < 1) { CanShoot == false; } if (totalAmmo > 0) { CanShoot == true; } { if (CanShoot == false) reload(); } if (CanShoot == true) { Shoot(); } function Shoot () { var ray: Ray = Camera.main.ScreenPointToRay(Vector3(Screen.width*0.5, Screen.height*0.5, 0)); if (Input.GetMouseButtonDown(0)) { if (Physics.Raycast (ray, hit, 100)) { hit.transform.SendMessage("ApplyDamage", TheDamage, SendMessageOptions.DontRequireReceiver); } } } function reload () { if(Input.GetKeyDown("r")) { yield WaitForSeconds(reloadTime); //waits for "reloadTime" before adding ammo ammoCount += reloadAmount; //adds ammo to our "clip" based off the reloadAmount totalAmmo -= reloadAmount; //subtracts whatever the reloadAmount was from our total ammo every time we reload } }

Viewing all articles
Browse latest Browse all 7934

Trending Articles



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