# Another question about the flying enemy

I want to make an enemy that can fly and I didn't find ani tutorials about it... I already made the enemy take off like helicopter, now this is my problem: after it taking off the land it need to follow me but when it not change his y axis (like it follow me in the air) but it coming to my plase.

How I make it follow me without it will change his y axis and it will not "look" at me?

That what i did so far:

``````var targetDistance;
var landDistance;
var target : Transform;
var land : Transform;
var inAirRange = 100.0;
var moveSpeed = 12.0;
var damping = 6.0;
private var isItAttacking = false;

function Update ()
{
landDistance = Vector3.Distance(land.position, transform.position);

if (landDistance <= inAirRange)
{
fly ();
}

else
{
stopFly ();
}

if(isItAttacking)
{
attack ();
}
}

function fly ()
{
isItAttacking = false;
renderer.material.color = Color.red;
transform.Translate(Vector3.up * moveSpeed *Time.deltaTime);
}

function stopFly ()
{
isItAttacking = true;
renderer.material.color = Color.black;
}

function attack ()
{
targetDistance = Vector3.Distance(target.position, transform.position);
var rotation = Quaternion.LookRotation(target.position - transform.position);
transform.rotation = Quaternion.Slerp(transform.rotation, rotation, Time.deltaTime * damping);
transform.Translate(Vector3.forward * moveSpeed *Time.deltaTime);
}

``````

Sorry for poor english.

for the following you can try

``````transform.position = new Vector3(  Vector3.Lerp(transform.position, target.position,Time.deltaTime).x, transform.position.y, transform.position.z);

``````

this will only get to make the transform close to you on x axis, cuz you kept the y and z values dont copy paste it, cus its on C#, just try to make it on js