Look left/right at target and not up/down (Solved)

I want a monster in my game to look only left and right at the target, so for example if my target jumps the target wont look up at him in his jump?
Im using this as a start:

var lookattarget : Transform;

function Update () {
	transform.LookAt(lookattarget);//this looks left/right/up/down and I want it to look only left/right
}

I guess I would have to use a vector 3 for this but im not exactly sure how to script it.

var target : Transform;
function Update ()
{
   transform.LookAt(Vector3(target.position.x, transform.position.y, target.position.z));
}

I’m not sure but i recon this might do it.
Its for aiming in 2d top down but it should do as you describe :slight_smile:

Awesome thank you very much works perfectly!

that took me days to figure out lol drove me nuts.

I’m glad to help

@That Homeless Guy: Thanks! Had pretty much the same problem and now it works!

wow, you r awesome to not be able to solve this binary sudoku … that’s really hard :smile: