When i let them follow my player this happens: Screenshot - 4974ae27d25bb9a20d72b2ab071d16b5 - Gyazo
They are rotating in z axis
This is my code that lets them move:
using UnityEngine;
using System.Collections;
public class EnemyAI : MonoBehaviour
{
Transform Hero;
public float AISpeed = 1f;
public float MaxDistance = 10f;
public float Mindistance = 2f;
void Start ()
{
Hero = GameObject.FindGameObjectWithTag("Player").transform;
}
void FixedUpdate ()
{
transform.LookAt (Hero);
AI ();
}
void AI()
{
if(Vector3.Distance (transform.position, Hero.position) >= Mindistance)
{
transform.position = Vector3.MoveTowards(transform.position, Hero.position, AISpeed);
if(Vector3.Distance (transform.position, Hero.position) >= MaxDistance)
{
}
}
}
}