Enemy Follow Disable Y Axis

Hello,
I have created a script to make an object follow the player, but my object follows on all 3 axes, when I only want it to move on the X and Z axes. My script is shown below:

var target : Transform; //the enemy's target var moveSpeed = 3;

//move speed var rotationSpeed = 3;
//speed of turning

var myTransform : Transform; //current
transform data of this enemy

function Awake() {
myTransform = transform; //cache transform data for easy
access/preformance }

function Start() {
target = GameObject.FindWithTag(“Player”).transform;
//target the player

}

function Update () {
//rotate to look at the player
myTransform.rotation = Quaternion.Slerp(myTransform.rotation,
Quaternion.LookRotation(target.position

  • myTransform.position), rotationSpeed*Time.deltaTime);

    //move towards the player
    myTransform.position += myTransform.forward * moveSpeed *
    Time.deltaTime;

}

You might want to use

Quaternion.LookRotation(Vector3(target.position.x, myTransform.position.y, target.position.z) - myTransform.position)

This would basically ignore the Y direction.