need help with Transform.LookAt

The Desired solution is quite simple. To have my enemies turn to face me the player.

The code is simply

function start()
{
if (target == null GameObject.FindWithTag(“Player”))
target = GameObject.FindWithTag(“Player”).transform;
}

function update()
{
transform.LookAt(target);
}

The problem When i use Transform.LookAt my enemies (who are taller than my player for the games sake)will turn on their X and Y axis to fire at me. I only want them turning on their Y axis.

However After staring at the Code for a few hours and trying random things to try and get the desired effect I have come to no avail.

transform.LookAt(Vector3(target.position.x, transform.position.y, target.position.z));

Thanks for that Help. I do not understand the full thing in it self but Let me give it a shot.

the transform.lookAt i know is the function.
The vector3 part is calling out that you want to specify personally what you want it to do.

Than the 3 parts you called
target.position.x
you were wanting it to say look at that

tranform.position.y
you were are telling unity to say move this axis only

target.position.z
is the same as X

If im wrong let me know I am glad it works and thanks im now just trying to as to how it worked.

target.position.x and target.position.z
means look at that position(player position) without the height parameter(y axis).

transform.position.y
means to never look up or down of your current position

if the player is at position 4, 5, 6(x, y, z) and the enemy is at 0, 2, 1 the enemy will look up if you use transform.LookAt(target); (wich is the same as transform.LookAt(Vector3(target.position.x, target.position.y, target.position.z)) and transform.LookAt(Vector3(4, 5, 6))) but if you use transform.LookAt(Vector3(target.position.x, transform.position.y, target.position.z)); the transform.position.y parameter means to look at his current Y axis wich is 2 in this case (the enemy will look at (4, 2, 6)).

Sorry about my english.

Cool that helps a lot with me understanding this. still trying to get down the whole programming aspect of Unity so every little bit helps.