3D Top down movement. Move towards the mouse position.

Hello, im making a 3d top down game, and now my movement script make the player look at the mouse position in the map by a rayCast, and move around with the getAxis(“Horizontal”) and getAxis(“Vertical”).
Basically my problem its when i press W the player mover vertically, and i want him to move in the direction he is looking.
Hope someone understand my question.

            void MovementTopDown()
        moveInput = new Vector3(Input.GetAxisRaw("Horizontal"), 0f, Input.GetAxisRaw("Vertical"));
        moveVelocity = moveInput * moveSpeed;

        Ray cameraRay = mainCamera.ScreenPointToRay(Input.mousePosition);

        Plane groundPlane = new Plane(Vector3.up, Vector3.zero);

        float rayLenght;

        if (groundPlane.Raycast(cameraRay, out rayLenght))
            Vector3 pointToLook = cameraRay.GetPoint(rayLenght);
            Debug.DrawLine(cameraRay.origin, pointToLook, Color.red);



    void FixedUpdate()
    rb.velocity = moveVelocity;

Okay, two things:

1.) You should never set the Rigidbody.velocity variable. You’re basically overriding the physics system, so when doing this you shouldn’t use a Rigidbody at all. Remove it.

2.) Your basic problem is that you need to convert your velocity from local space (forward is the entity’s forward) to world space (forward is Z+ axis). To do this, you can use the Transform.TransformVector() function, then use that as the actual velocity.