Controlling Raycasts (2D)

How do you make a raycast determine what colliders to detect/hit?

i watched 2 tutorials now but it didn’t show.

Also, can you determine the thickness of a raycast? or do you just have to have more than 1 spaced apart?

You can control which colliders the raycast hits using a layermask. Check which versions of Raycast include a LayerMask here: https://docs.unity3d.com/ScriptReference/Physics2D.Raycast.html

A raycast is a dimensionless ray, so it is always an infinitely thin laser beam. You can however use BoxCast or CircleCast or CapsuleCast instead if you want a “thick” raycast.

Thanks Praetor, also, how can I stop my raycast hitting its own collider?