Quantcast
Channel: Questions in topic: "gun"
Viewing all articles
Browse latest Browse all 592

Adding muzzle flash to the unity

$
0
0
#pragma strict var Rounds : int; var Ammo : int; var Reloading : boolean; var MaxAmmo : int = 20; var theDammage = 100; var delay = 0.1; var timestamp = 0.0; var ReloadTime = 1.8; private var reloading : boolean = false; function Start() { GetComponent.().Play("Idle",PlayMode.StopAll); } function Update () { var hit : RaycastHit; var ray : Ray = Camera.main.ScreenPointToRay(Vector3(Screen.width*0.5, Screen.height*0.5, 0)); if(Rounds == 0 && Ammo == 0 ) { return; } if (Ammo <= 0 && Rounds >= 0 ) { Reloading = true; GetComponent.().Play("Reload",PlayMode.StopAll); Reload(); } else { if (timestamp <= Time.time && Physics.Raycast (ray, hit, 10) && Reloading == false) { timestamp = Time.time + delay; if(hit.collider.gameObject.tag == "Dobj") { Ammo--; GetComponent.().Play("Fire",PlayMode.StopAll); GetComponent.().Play(); hit.transform.SendMessage("ApplyDammage", theDammage, SendMessageOptions.DontRequireReceiver); } } } } function Reload() { yield WaitForSeconds (1); if(Ammo == 0 && !Reloading) { Rounds --; Reloading = true; Ammo = MaxAmmo; } Reloading = false; } I Want to add a muzzle flash to the gun the gun automatically fires if the gun aims on enemy......thanks in advance.........I am not using particle renderer ...i am using A simple plane

Viewing all articles
Browse latest Browse all 592

Trending Articles



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