Currently, all my script does is make them fly and follow the player (which is cool but not what I’m looking for for most of the enemies), I’m trying to have enemies actually walk on the ground like the player does, here’s the script I’m using
`using UnityEngine;
using System.Collections;
public class Enemy_movement : MonoBehaviour {
public Transform target;
public int moveSpeed;
public int rotationSpeed;
void Start()
{
target = GameObject.Find("Michael").transform;
}
void Update()
{
if (target != null)
{
Vector3 dir = target.position - transform.position;
// Only needed if objects don't share 'z' value.
dir.z = 0.0f;
if (dir != Vector3.zero)
transform.rotation = Quaternion.Slerp ( transform.rotation,
Quaternion.FromToRotation (Vector3.right, dir),
rotationSpeed * Time.deltaTime);
//Move Towards Target
transform.position += (target.position - transform.position).normalized
* moveSpeed * Time.deltaTime;
}
GetComponent<Rigidbody2D>().velocity = Vector3.zero;
}
}`
any suggestions on what to change (I’m still very new to game design and am using other posts to help me put my code together)