Пример #1
0
    public void TryToTriggerGun()
    {
        if (shootCounter <= 0)
        {
            gunShootSound.Stop();
            gunShootSound.pitch = Random.Range(0.8f, 1);
            gunShootSound.Play();

            this.transform.DOShakeRotation(MinimumShootPeriod * 0.8f, 3f);

            muzzleCounter = muzzleShowPeriod;
            muzzleFlash.transform.localEulerAngles = new Vector3(0, 0, Random.Range(0, 360));

            shootCounter = MinimumShootPeriod;
            GameObject   newBullet = GameObject.Instantiate(bulletCandiate);
            BulletScript bullet    = newBullet.GetComponent <BulletScript>();
            bullet.transform.position = muzzleFlash.transform.position;
            bullet.transform.rotation = muzzleFlash.transform.rotation;

            bullet.InitAndShot(muzzleFlash.transform.forward);
        }
    }