I have created an empty game object and turrets image which i have made a child object of the game object,whenever an enemy is spawned ,it beahves randomly doesnt tries to loook at the enemy direction,just rotates around itself randomly,i have attached my script to the parent game object,here is my script
using UnityEngine;
using System.Collections;
public class Turret : MonoBehaviour
{
private GameObject target;
void Start(){
}
void Update()
{
if(target != null){
transform.LookAt (target.transform, Vector3.up);
}
else{
target = GameObject.FindGameObjectWithTag ("enemy");
}
}
}