Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var projectile : Rigidbody;
- var projectileVelocity = 10;
- var BulletSound : GameObject;
- var WeaponReloadeSound : GameObject;
- var timeToDestroyBullet =3.0;
- var CanIShoot = 0;
- static var ammo = 3;
- static var clipForAmmo = 12;
- var timeToShoot = 0.3;
- var reloadedTime = 1;
- function Update ()
- {
- if (Input.GetButtonDown("Fire1"))
- {
- if(clipForAmmo > 0 && CanIShoot==0)
- {
- CanIShoot = 1;
- var instantiateProjectile : Rigidbody = Instantiate(projectile, transform.position, transform.rotation);
- clipForAmmo -= 1;
- Invoke("ICanShoot", timeToShoot);
- }
- }
- if (clipForAmmo == 0 && ammo>0)
- {
- if(Input.GetButtonDown ("Reload"))
- {
- WeaponReloadeSound.audio.Play();
- Invoke("reloadWeapon", reloadedTime);
- }
- }
- }
- function reloadWeapon ()
- {
- clipForAmmo = 12;
- ammo --;
- }
- function ICanShoot ()
- {
- CanIShoot = 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement