using System.Collections; using System.Collections.Generic; using UnityEngine; public class EnemyController : MonoBehaviour { public Transform target; public float speed; private Rigidbody2D _rb; // Start is called before the first frame update void Start() { _rb = GetComponent(); } // Update is called once per frame void FixedUpdate() { var diff = target.position - transform.position; diff.Normalize(); _rb.AddForce(diff * speed); } }