Lock Homing Missile to Plane (2D)

I am trying to make a missile that follows the player, one that rotates towards the direction of the player and generally acts as a homing missile does. The homing code works fine. However, it’s a 2D game and I find my missile doing loop-de-loops onto the Z-axis when trying to find my player even though I want the missile to be bound to the X-Y plane.

Here is the code i’m using for the homing enemy (javascript)

var target : Transform; 
var moveSpeed = 4;
var rotationSpeed = 1;

var life = 0;

function Awake()

function Start()
target = GameObject.FindWithTag("Player").transform;
transform.rotation = Quaternion.LookRotation(target.position - transform.position);

function FixedUpdate()
var lookDir = target.position - transform.position;
//lookDir.z = 0;
transform.rotation = Quaternion.Slerp(transform.rotation, Quaternion.LookRotation(lookDir), rotationSpeed*Time.deltaTime);
transform.position += transform.forward * moveSpeed * Time.deltaTime;

function Update()
life = life + 1;
if (life > 300)

you’ll notice the lookDir.z = 0 code commented out. This was my attempt at fixing it, however the code caused odd things to occur.

Again, homing itself works fine, but how do I lock the missile to the x-y plane, preventing them from moving in the z-direction at all?

I guess, the Missile and Player z-coords are not exactly the same. In this case missile should twitch of cause.

Try to set transform.positino.z = target.transform.position.z in Start (before calculate rotation).
And in FixedUpdate too (to avoid changing of z because of float round operations).