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

//Marvin Schneider
public class EnemyMovementMelee : MonoBehaviour
{
    public GameObject player;
    public EnemyStats enemyStats;
    public float targetDistance;

    private float distance;


    void Start()
    {
        enemyStats = GetComponent<EnemyStats>();
    }

 
    void Update()
    {
        if(player != null){

            distance = Vector2.Distance(transform.position, player.transform.position);

            Vector2 direction = player.transform.position - transform.position;
            direction.Normalize(); 


            if (distance < targetDistance)
            {
                transform.position = Vector2.MoveTowards(transform.position, player.transform.position, enemyStats.speed * Time.deltaTime);
            }
        }
    }
}
