How can I add a second tag to this turret script?

Hi all!

My turret script looks for GameObjects with the tag “Enemy” and sets them as target.
I have added a new enemy with the tag “Enemy2”, however I can’t get the turret to recognise him as a target. Here is the turret script:

    using UnityEngine;
    using System.Collections;

    public class Turret : MonoBehaviour {
    private Transform target;

	[Header("Attributes")]

	public float range = 15f;
	public float fireRate = 1f;
	private float fireCountdown = 0f;

	[Header	("Unity Setup Fields")]

	public string enemyTag = "Enemy";
	public string enemyTag2 = "Enemy2";

	public Transform turretHead;
	public float turnSpeed = 10f;

	public GameObject bulletPrefab;
	public Transform firePoint;

	void Start () 
	{
		InvokeRepeating ("UpdateTarget", 0f, 0.5f);	
	}

	void UpdateTarget ()
	{
		GameObject[] enemies = GameObject.FindGameObjectsWithTag (enemyTag);
		float shortestDistance = Mathf.Infinity;
		GameObject nearestEnemy = null;

		foreach (GameObject enemy in enemies) 
		{
			float distanceToEnemy = Vector3.Distance (transform.position, enemy.transform.position);
			if (distanceToEnemy < shortestDistance) 
			{
				shortestDistance = distanceToEnemy;
				nearestEnemy = enemy;
			}

		}

		if (nearestEnemy != null && shortestDistance <= range) {
			target = nearestEnemy.transform;
		} else 
			{
				target = null;
			}

	}

	void Update () 
	{
		if (target == null) 
		{
			return;	
		}

		Vector3 dir = target.position - transform.position;
		Quaternion lookRotation = Quaternion.LookRotation (dir);
		Vector3 rotation = Quaternion.Lerp(turretHead.rotation, lookRotation, Time.deltaTime * turnSpeed).eulerAngles;
		turretHead.rotation = Quaternion.Euler (0f, rotation.y, 0f);

		if (fireCountdown <= 0f) 
		{
			Shoot ();
			fireCountdown = 1f / fireRate;
		}

		fireCountdown -= Time.deltaTime;
	}

	void Shoot()
	{
		GameObject bulletGO = (GameObject)Instantiate (bulletPrefab, firePoint.position, firePoint.rotation);
		Bullet bullet = bulletGO.GetComponent<Bullet> ();

		if (bullet != null)
			bullet.Seek (target);	
		
	}
     }

I have tried adding another tag to the code like this:

           GameObject[] enemies = GameObject.FindGameObjectsWithTag (enemyTag || enemyTag2);
           GameObject[] enemies = GameObject.FindGameObjectsWithTag (enemyTag && enemyTag2);
           GameObject[] enemies = GameObject.FindGameObjectsWithTag (enemyTag, enemyTag2);
           GameObject[] enemies = GameObject.FindGameObjectsWithTag (enemyTag) && ( enemyTag2);

But nothing works… This is the last bit of code I need to complete the basics of my game! :smiley:
Any help would be appreciated.

Change the line GameObject[] enemies = GameObject.FindGameObjectsWithTag (enemyTag); to this code:

//Get reference of all enemies
GameObject[] ene1 = GameObject.FindGameObjectsWithTag(enemyTag);
GameObject[] ene2 = GameObject.FindGameObjectsWithTag(enemyTag2);

//New array with all enemies
GameObject[] enemies = new GameObject[ene1.Length + ene2.Length];

//Copy all enemies to new array
ene1.CopyTo(enemies, 0);
ene2.CopyTo(enemies, ene1.Length);

This gets the references of all GameObjects tagged as enemyTag and enemyTag2 and puts them on GameObject[] enemies.