How can I fire a raycast from a gameobject to the cursor position?

I want to have a raycast firing from the character to the cursor position
I have no idea where to start
can anyone help me?

Camera.ScreenpointToRay (Input.mousePosition); does this help? here’s the unity reference: Unity - Scripting API: Input.mousePosition