Пример #1
0
    void FireGun()
    {
        if (Input.GetButton("Fire1"))
        {
            if (fireRateTimer <= 0f)
            {
                //Debug.Log("Fire!");
                GameObject bullet = Instantiate(gunProperties.GetBulletPrefab(), gunProperties.GetBulletTransform().position, gunProperties.GetBulletTransform().rotation, gunProperties.GetBulletsInHierarchyTransform());
                fireRateTimer = gunProperties.GetFireRate();
                shootAudio.Play();
            }
        }

        fireRateTimer -= Time.deltaTime;
    }
Пример #2
0
 // Use this for initialization
 void Start()
 {
     gunProperties = GetComponent <GunProperties>();
     fireRateTimer = gunProperties.GetFireRate();
     shootAudio    = GetComponent <AudioSource>();
 }