How to use RaycastHit2D for a 2D projectile?

I have a small, fast-moving 2D projectile that shoots from my player in the left and right direction. Due to the size and speed of the object, it can often pass through other game objects.

I found a few tutorials that go over this using Vector3’s and mouse position; however, my game uses neither of those.

Can anyone help me set up a simple RaycastHit2D that I can use on this projectile object?

Are you using RigidBody2D? If so before trying the raycast route, have you tried setting the Collision Detection mode to continuous and Interpolate mode To Interpolate on your RigidBody2D?

That is what I am currently using, however, the issue still arises where the projectile will sometimes pass through collision. I see that Raycasting is the best method to solve this issue, so that is the method I am hoping to learn to implement in a 2D setting.