How do you make an object follow the mouse on the x and z axes?

I am making a top-down game, but I do not know how to make the player object follow the mouse on only the x and z axes.
I tried this:
`public Camera camToUse;
public Transform CubeToTransform;

void Update()
{

    Ray ray;
    RaycastHit hit;
    ray = camToUse.ScreenPointToRay(Input.mousePosition);
    if (Physics.Raycast(ray, out hit, 100.0f))
    {

        CubeToTransform.transform.position = hit.point;

    }
}`  

It was good for what I need except that it caused the object to go towards the camera and I did not want that.

Hi!

You can try just remapping the values through a new vector:

CubeToTransform.transform.position = new Vector3(hit.point.x, CubeToTransform.transform.position.y, hit.point.y);