Firing a Missile from moving Craft

Hi I have aircraft flying over and a
ground based gun tracking and
firing.This is a 2D game and aircraft
move in Z=-1,the gun is in Z=-1 and
bullets and missiles are supposed to
move only in z=-1.The aircraft are
spawned based on prefabs and these
aircraft will in turn instantiate
missiles and fire at the
gun.Everything works well except that
the missiles get a velocity in Z and
hence hit the gun only some times.The
code for instantiating Missiles and
adding force (from aircraft ) is below.

Also ,the GunTurret objects transform has z=-1.In fact I went into debugger and looked at
shootDirection variable and it has Z=0,since source and target are at z=-1.

		var position=transform.position;
		GameObject missile = (GameObject)Instantiate(Manager.GetEnemyMissile(),
		                                       new Vector3(position.x,position.y-10.0f,Manager.POSITION.Zaxis),
		                                           Quaternion.identity);
		var shootDirection = Manager.ManagerInstance.GunTurret.transform.position-missile.transform.position;

	    missile.rigidbody.AddForce(shootDirection*Manager.SPEED.Missile);

Also ,the GunTurret objects transform has z=-1.In fact I went into debugger and looked at
shhotDirection variable and it has Z=0,since source and target are at z=-1.

On your missile prefabs, open the ‘constraints’ dropdown, and check ‘z-position’. This should prevent the bullets from moving on the Z-axis.