Well, I'm having trouble making the enemy follow the player, I made the code below:
public class folow : MonoBehaviour {
public Transform target;//set target from inspector instead of looking in Update
public float speed = 3f;
private Transform myTransform;
void Start()
{
myTransform = this.GetComponent<Transform>();
}
void Update()
{
//rotate to look at the player
transform.LookAt(target.position);
transform.Rotate(new Vector3(0, -90, 0), Space.Self);//correcting the original rotation
myTransform.position = Vector2.MoveTowards(transform.position, target.position, speed * Time.deltaTime);
}
The problem is that it just tries to go towards the player, but can not dodge objects and gets stuck in any obstacle