Aiming with the mouse in a 2d shooter, and then shooting to the mouse

So I was wondering how I can use the mouse to aim in my 2d sidescroller and then shoot to where the cursor is. I’ve looked at some questions asked on this site that are like mine already, but so far none of them have helped. Any help is most appreciated. Thank you all in advance.

You can add a box collider in front of the camera then use Physics.Raycast and ScreenPointToRay. Or Plane.Raycast with a Plane( Vector3.back, Vector3.zero ).

I have an invisible plane in my scene that is used to calculate the position of the mouse pointer in the 3D game world:

private var layerMask  = 1 << 8;   //plane is on layer 8

if(Physics.Raycast(Camera.main.ScreenPointToRay(Input.mousePosition), mousPos, Mathf.Infinity, layerMask)){
    //lookAt mousPos.point
}

(should be even easier in a top down 2D shooter)

For shooting:

if(Input.GetKey(KeyCode.Mouse0)) {
    //shoot
}