How can I Raycast through the Player?

I have seen an answer to this before but I can no longer find it. I have a gun and as of know it Raycasts from about the center(it changes so that the gun isn’t perfectly accurate). All you have to do is look down and the Raycast hits the player(making sparks). I want it to just skip through and hit the ground.

set the Players Layer to “Ignore Raycast”

Cast the Raycast only to a defined layer… Something like:

1 << LayerMask.NameToLayer("YourTargetLayerName")