Пример #1
0
        private void SpawnGoodBullet() // Method to spawn GoodBullets
        {
            if (timerSpawnBullet > 0)
            {
                return;                                                                                   // If still on cooldown, don't spawn a bullet
            }
            SoundBoard.PlayPlayerShoot();                                                                 // Play player shoot sound
            GoodBullet p = Instantiate(prefabGoodBullet, barrel.transform.position, Quaternion.identity); // Instantiate a bullet at the barrel of the pod

            p.InitBullet(transform.forward * 20);                                                         // Sest the velocity of the bullet

            timerSpawnBullet = 1 / roundsPerSecond;                                                       // Sets the cooldown before another bullet can spawn
        }
Пример #2
0
        void SpawnGoodBullet()
        {
            if (timerSpawnBullet > 0)
            {
                return;                       // need to wait longer
            }
            if (roundsInClip <= 0)
            {
                return;                    // no ammo
            }
            GoodBullet p = Instantiate(prefabGoodBullet, transform.position, Quaternion.identity);

            p.InitBullet(transform.forward * 20);

            roundsInClip--;
            timerSpawnBullet = 1 / roundsPerSecond;
        }