Enemies won't attack after they spawn!

I am trying to make my enemies attack my player after they spawn but they just run towards the player, stop, and don’t attack. I am making the spawner use the enemy prefab, but when I actually place the enemy in the scene it works. Although when I kill the first enemy they stop spawning. Is there a way to make it so my enemies always look for my player and attack him?
Here is my spawn script:

using UnityEngine; using System.Collections;

public class Spawn : MonoBehaviour {
// Spawn location
public Vector3 spawnLocation = Vector3.zero;
// Spawn radius (Gives a bit more randomness factor to the spawn location)
public float spawnRadius = 1.0f;
// Spawn timer (seconds)
public float spawnTimer = 5.0f;
private float spawnTimeRemaining = 5.0f;
public GameObject enemyPrefab;

// The zombie to spawn public GameObject zombiePrefab = null;

void Awake() { spawnTimeRemaining = spawnTimer; }

void FixedUpdate() { spawnTimeRemaining -= Time.deltaTime;
	if (spawnTimeRemaining <= 0)
		Vector2 circlePosition = Random.insideUnitCircle * spawnRadius;
		GameObject.Instantiate(enemyPrefab, spawnLocation + new Vector3(circlePosition.x, 0.0f, circlePosition.y), Quaternion.identity);
		spawnTimeRemaining = spawnTimer;


Any help would be awesome. Thanks :smiley:

Question “why they wont atytack you” - is not about Spawner code, but its about Zombie code…

And what about “why spawner dont spawn new ones after you killed first”: what have you linked to spawner’s enemyPrefab field in inspector? you should drag-n-drop a prefab from project window, not zombie from scene. If you linked zombie from scene, it will cause such error (because spawner’s enemyPrefab will to nothing after zombie is killed). I assume this is the most likely cause.