How to track the intersection of lines with objects?

Hello everyone, I’m trying to teach the square to bypass obstacles, so I think lines are looking for ways to bypass.

I just don’t know how to check whether the line intersects with a physical object or not.

How do you teach an object to bypass obstacles in general, maybe you can advise other solutions?



Screenshot_5

It’s decided.


Screenshot_7