Problems with Collision Raycast with the source object self

Hello,

I often find a bad problem using Raycast.
I’m using a ray to verify if two objects can see one to each other (no obstacles between them).
So I use Collider.Raycast() to check this visibility.
The problem is either “source” object and “target” object have Colliders, and when I send the ray from the source object, the ray immediately collide with the object self!
So I tried to use Physics.Raycast but the result is the same.
Now I can use Layers but, is there any other way to avoid this?

Thank you!

you should be able to attach an empty game object to your collider object (say slightly infront of it and outside of the bounding volume) and shoot the ray from this empty game object’s position instead of the collider.
But using layers would probably be better.

Ok, I was thinking to layers (even for optimization purposes), but I was looking for alternatives (even for general knowledge).

Thank you!