Пример #1
0
    // Spawns a bullet at the spawn position
    void Shoot()
    {
        // If the player isn't holding the tower
        if (canShoot)
        {
            Debug.Log("Shoot");
            // Spawn a bulletPrefab at the muzzle of the tower, get the BulletScript on the prefab, and play the audio from the AudioManager
            GameObject   bullet       = (GameObject)Instantiate(bulletPrefab, bulletSpawnPoint.position, bulletSpawnPoint.rotation);
            BulletScript bulletScript = bullet.GetComponent <BulletScript>();
            AM.PlayProjectileSound();

            //If a bullet exists, assign a target to the bullet to travel to
            if (bullet != null)
            {
                bulletScript.AssignTarget(target);
            }
        }
    }