There are many types of 3D raycasts.
One is the generic Physics one: hits anything in the scene
Another is one that lives on a collider.
If you know which collider you care about, you can use that collider instance to see if a ray hits it.
That way you not only know that it hit, but because you are already asking “Did anything hit this collider?” you also know what collider it is.
These are some of the types of 3D raycasts:
- asks “did I hit anything in the scene?”
- asks “did I hit this specific collider?”
- asks “did I hit this plane?”
They are unrelated to each other but related conceptually.