using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Enemy : MonoBehaviour {

    public Transform Player;
    public float MoveSpeed = 0;
    public float MaxDist = 10;
    public float MinDist = 5;
    bool huida;
    float creacion;
    Vector3 movRandom;

    void Start()
    {
        huida = false;
        //transform.Rotate(new Vector3(-90,0,0));
        creacion = Random.value;
    }

    void Update()
    {
        transform.LookAt(Player);
        //transform.Rotate(new Vector3(-90, 0, 0));  
        if (huida)
        {
            float h = Mathf.PerlinNoise(creacion, Time.time / 1) - 0.5f;
            float v = Mathf.PerlinNoise(creacion + 1, Time.time / 1) - 0.5f;

            movRandom = new Vector3(h, 0, v);

            transform.position += movRandom;
        }
    }

    void Huir()
    {
        huida = true;
    }
}
