Im trying to get it to where my enemy will follow the player. The one problem is that it moves up no matter what I do.
my script c#
using UnityEngine;
using System.Collections;
public class Enemy : MonoBehaviour {
public Transform target;
public float distance;
public float lookAtDistance;
void Start () {
}
// Update is called once per frame
void Update () {
distance = Vector3.Distance(target.position, transform.position);
if (lookAtDistance > distance) {
transform.position = Vector3.MoveTowards (transform.position, target.transform.position, 0.03f);
}
}
}