Ray to set Y depth

So, I’m working on a space RTS sample and I’m working on the unit movement. What I want to do is find a way to get the position where the mouse clicked all the way down to the units current y. So if the unit is on y=50 the ray will go all the way down and forward from the camera and hit on the y=50. This could be accomplished by placing a collider there but it seems like there should be easier or more direct answer.

Basicly, what I want to do is go down the ray till the Y=UnitY.

ah ha, figured it out. Need to use a ‘Plane’

Ray mouseRay = Camera.main.ScreenPointToRay(Input.mousePosition);
Vector3 endPoint = Vector3.zero;

Plane plane = new Plane(Vector3.up, ship.transform.position);
float distance = 0.0f;
plane.Raycast(mouseRay, out distance);

endPoint = mouseRay.GetPoint(distance);