Turret on Tank rotating fine until I'm not flat on ground

I have a TANK with a Turret on top, the turret follows my mouse around the screen and it rotates perfectly. And the turret never clips into the tank thanks to x and z being zerod out. When my tank is climbing a hill though the turret goes right through the tank. I think it has something to do with local angles or something but I can’t figure it out.

SEE IT HERE - http://dl.dropbox.com/u/24020723/GAME/TANK.html Take the tank onto a hill and see what happens to turret
Thanks!

	    Plane zeroPlane = new Plane( Vector3.up, Vector3.zero );
	    Ray ray = Camera.main.ScreenPointToRay( Input.mousePosition );
	    float distance;
	    if( zeroPlane.Raycast( ray, out distance ) )
	   {
			  Vector3 outputPosition = ray.origin + ray.direction* distance;	
		      var newRotation = Quaternion.LookRotation(outputPosition-turretRotate.position).eulerAngles;
  			  newRotation.x = 0;
  			  newRotation.z = 0;
   			  turretRotate.rotation = Quaternion.Euler(newRotation);

}

I ran into the same issue when doing a tank with turret before.
You’ll need to use Transform.localRotation in order to use the local object’s up / Y axis in the Quaternion.AngleAxis method:

Transform turretTransform = transform.Find ("Turret");
turretTransform.localRotation = Quaternion.AngleAxis (turretAngle, Vector3.up);

Looks obvious, but still took a while to figure out.

Note that you may have to change Vector3.right to Vector3.up or Vector3.forward in this line of code, depending on the axis containing the longest direction (I’d recommend reexporting the object though, as it would make it more intuitive while programming).