using System.Collections; using System.Collections.Generic; using UnityEngine; public class FollowingEnemy : Enemy { public Transform target; public float chaseRadius; public float attackRadius; public Transform homePosition; public Transform[] path; public int currentPoint; public Transform currentGoal; public float roundingDistance; private Rigidbody2D myRigidbody; public Animator anim; // Start is called before the first frame update void Start() { myRigidbody = GetComponent(); anim = GetComponent(); target = GameObject.FindWithTag("Player").transform; } // Update is called once per frame void Update() { CheckDistance(); } void CheckDistance() { if(Vector3.Distance(target.position, transform.position) <= chaseRadius) { transform.position = Vector3.MoveTowards(transform.position, target.position, moveSpeed * Time.deltaTime); } } }