Re-target new Enemy

Hello!
I have one Problem that my Object is attacking only one enemy and then the other one get not harmed. (because of my Awake Function) but I dont know how to fix this issue into the Update Function (The FindwithTag & Healththing(?))

Here is my code so far:

using UnityEngine;
using System.Collections;


public class SkeletonWarriorAttack : MonoBehaviour
{
	public float timeBetweenAttacks = 0.5f;     // The time in seconds between each attack.
	public int attackDamage = 13;               // The amount of health taken away per attack.

	
	GameObject playereast;					        // Reference to the player GameObject.
	ElvenWarriorHealth eastHealth;                  // Reference to the player's health.
	SkeletonWarriorHealth westHealth;               // Reference to this enemy's health.
	bool playerInRange;                         // Whether player is within the trigger collider and can be attacked.
	float timer;                                // Timer for counting up to the next attack.
	
	
	void Awake ()
	{
		// Setting up the references.
		playereast = GameObject.FindGameObjectWithTag ("PlayerEast");
		eastHealth = playereast.GetComponent <ElvenWarriorHealth> ();
		westHealth = GetComponent<SkeletonWarriorHealth>();
	}
	
	void OnTriggerEnter (Collider other)
	{
		// If the entering collider is the player...
		if(other.gameObject == playereast)
		{
			// ... the player is in range.
			playerInRange = true;
		}
	}
		
	void OnTriggerExit (Collider other)
	{
		// If the exiting collider is the player...
		if(other.gameObject == playereast)
		{
			// ... the player is no longer in range.
			playerInRange = false;
		}
	}
	
	 void Update ()
	{
		// Add the time since Update was last called to the timer.
		timer += Time.deltaTime;
		// If the timer exceeds the time between attacks, the player is in range and this enemy is alive...
		if(timer >= timeBetweenAttacks && playerInRange && westHealth.currentHealth > 0)
		{
			Attack ();
		}
	}

	 void Attack ()
	{
		// Reset the timer.
		timer = 0f;
		// If the player has health to lose...
		if(eastHealth.currentHealth > 0)
		{
		// ... damage the player.
		eastHealth.TakeDamage (attackDamage);
		}
	}
}

Maybe it is possible to do it with something like:

GameObject targets = GameObject.FindGameObjectsWithTag (“PlayerEast”);
foreach (GameObject target in targets)

{

//tell the update function that this target is now “Targeted” and is going to be attacked! (?)

}

but I don’t know how to get any further with this issue…

Thanks for your time!
Flowered

I now see you’re creating a detection system. Entity discovery (one entity seeking another) is often best handled with triggers.

Do not rely on Finds for reference management. Ideally all entities should belong to some collection and get “found” by having access to that collection. (e.g. a GameManager singleton who keeps collections of like entities.)

Triggers (or Finds obviously) would work in this scenario too, but the manager singleton approach to reference management is a super great way to manage complex scenes. These are concepts that may be biting off a bit much right now, but I’d feel irresponsible if I didn’t mention them.

You need some way for your seeker objects to find their sought objects. A Find() is fine for now. Whatever approach you choose to satisfy this requirement must support changing targets when the current target is no longer available. Whatever approach you choose will give you some collection of discovered sought objects. Your new current target becomes the next discovered sought object in that collection. You’ll need to run the Find() again to re-discover the object(s) you’re seeking, or at the very least, make provisions to deal with nullified elements.