Enemy chasing player script
[SerializeField] private float MoveSpeed = 4;
[SerializeField] private float MaxDist = 10;
[SerializeField] private float MinDist = 5;
function Update ()
{
transform.LookAt(Player);
if(Vector3.Distance(transform.position,Player.position) >= MinDist)
{ transform.position += transform.forward*MoveSpeed*Time.deltaTime;
if(Vector3.Distance(transform.position,Player.position) <= MaxDist)
{
//Here Call any function U want Like Shoot at here or something
}
}
}