/* Summary: * Burst fire is how shotguns and burst fire guns opperate for this script. * To make a shotgun bring up bullets count and reduce the lagtime to less then .1 * * for a generic burst fire rifle bullets count from around 3-5 and set the burst to around .2 to .5 depending on what you want * * for a single shot gun just set bullets to 1 */ public void Burst() { if (toFast == true) { Shoot(); toFast = false; } Vector3 mouseDir = CameraController.instance.cam.ScreenToWorldPoint(Input.mousePosition) - new Vector3(transform.position.x, transform.parent.position.y); float angle = Mathf.Atan2(mouseDir.y, mouseDir.x) * Mathf.Rad2Deg; angle = angle + Random.Range(-deviation, deviation); // Sets the devation to this variable Quaternion bulletDev = Quaternion.Euler(new Vector3(0, 0, angle)); //Bullet pooling GameObject bul = BulletPool.GetBullet(); bul.transform.position = new Vector3(transform.position.x, transform.parent.position.y); //bul.transform.rotation = bulletDev; bul.SetActive(true); bul.GetComponent <Projectile>().bulletSet(damage, speed, bulletDev * Vector2.right, bulletLife, false, transform.root.gameObject, transform.localPosition.y); // Used to make sure that a ton of particles dont spawn if (toFast == true) { Shoot(); } //resets burst timer and removes bullet bullets -= 1; if (bullets == 0) { //Resets stuff toFast = true; burstBool = false; bullets = bulletsReset; triggerDelay = triggerDelayReset; clip -= costToShoot; // updates ui GameObject.Find("UiManger").GetComponent <UiGun>().ammoClipSet(clip, ammoPool); } }
public void Shoot() { GameObject bullet = bulletList.GetBullet(); if (!Crouch) { bullet.GetComponent <BulletScript>().BulletHolder = ShootPoint; } else { bullet.GetComponent <BulletScript>().BulletHolder = ShootPoint2; } if (horizontal != 0 && !isWalking) { bullet.GetComponent <BulletScript>().BulletHolder = ShootPoint3; } bullet.GetComponent <BulletScript>().ShotByPlayer = true; bullet.GetComponent <BulletScript>().FacingRight = controller.m_FacingRight; bullet.SetActive(true); }