how to to make transform.LookAt not be able to rotate on a certain axis

So i’ve tried this using quaternion/Slerp/Vectore 3, but it hasn’t worked out well for me…

So basically i have a player, this player is going to be chased by a NPC (the npc will constantly rotate towards them and move towards them as the player moves) The problem i have is that when i have my player that’s being chased jump, the NPC will rotate it’s whole body to face upwards on the Z axis towards me… which i don’t want to happen. (this is 3D btw)

code:

void chase()
	{
		transform.LookAt (player.position);
		controller.SimpleMove(transform.forward*speed);
	}
/*chase is called every frame in the update method (making it hard for me to use vectors..*/

You can do the calculation yourself and set the rotation.

void chase()
{
	Quaternion rotation = Quaternion.LookRotation(player.position);
	rotation.eulerAngles = new Vector3(0, rotation.eulerAngles.y, 0);
	transform.rotation = rotation;
	controller.SimpleMove(transform.forward*speed);  
}