I Want To Move Character To Where My Mouse

I Want To Move Character To Where My Mouse Is Using Invisible Plane So it Doesn’t Go Up Wall

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class MouseController : MonoBehaviour
    public Camera camera;

    // Update is called once per frame
    void Update()

        Ray cameraRay = camera.ScreenPointToRay(Input.mousePosition);
        Plane groundPlane = new Plane(Vector3.up, Vector3.zero);
        float rayLength;

        if(groundPlane.Raycast(cameraRay, out rayLength))
            Vector3 hit = cameraRay.GetPoint(rayLength);
            Debug.DrawLine(cameraRay.origin, hit, Color.blue);

            transform.Translate(hit.x, 0f, hit.z);

It look like you don’t understand how to use the Raycast. I don’t know what is that groundPlane for but it is useless in this code. Instead, you should use cameraRay to Raycast. The correct code should be:
`NavMeshAgent nav;
RaycastHit hit;
LayerMask movementMask;

if (Physics.Raycast(cameraRay, out hit, 100, movementMask))
// do some thing like