Unity3D: I don't know how to only reflect in the X-Z axis

I want a reflection of a ray but only in the X-Z axis, while the Y-axis should only allow me to adjust the height of the reflection, but have no impact on the reflection itself;

Here’s the regular reflection:

  if (Physics.Raycast(ray.origin, ray.direction, out hit, remainingLength))
            {
              
                lineRenderer.positionCount += 1;
                lineRenderer.SetPosition(lineRenderer.positionCount - 1, hit.point);
                remainingLength -= Vector3.Distance(ray.origin, hit.point);
              
                //temp_normal.x = ray_new.x;
                ray = new Ray(hit.point, Vector3.Reflect(ray.direction, hit.normal));

Here’s my attempt, I tried making the ray origin’s y the same as the hit point’s y in hopes that it would automatically give me a X-Z reflection, alas to no avail:

var hit_2 = hit ;
                //Make a new ray with the same y position as the hit point so it doesn't reflect in y
                var ray_2= new Ray(new Vector3(transform.position.x,hit.point.y,transform.position.z), transform.forward);
                Physics.Raycast(ray_2.origin, ray_2.direction, out hit_2, remainingLength);
              
                lineRenderer.positionCount += 1;
                lineRenderer.SetPosition(lineRenderer.positionCount - 1, hit.point);
                remainingLength -= Vector3.Distance(ray.origin, hit.point);
              
                //temp_normal.x = ray_new.x;
                ray = new Ray(hit.point, Vector3.Reflect(ray_2.direction, hit.normal));
                if (hit.collider.tag == "Totem")
                {
                    //lineRenderer.material.color = new Color(0.4f, 0.9f, 0.7f, 1.0f);
                  
                    break;
                }

I’m not 100% sure what you mean by

but instead of setting the y component of the ray’s origin to the hit point (the ray origin already is the hit point in the original snippet btw), try making the y component of the ray’s direction vector 0. So instead of using Vector3.Reflect(ray.direction, hit.normal) directly, store it in a variable, set its y value to 0 and use that as the second parameter of Physics.Raycast().

This works! Someone on stackoverflow commented the same thing and it works exactly how I want it