How detect obstacles between the camera and the target?

Hey~All, I try to realize a function of removing obstacles between the camera and the observation target. My first thought is to use the rays emitted from the lens to detect whether the mesh is an obstacle. But there seems to be a problem with my understanding of rays. In my code, it does not return the detection results I want.
The result I expect:


1 Like

A simplified approach which may be of help to you

Your PG + rayHelper to show ray

This may also help Mesh Picking | Babylon.js Documentation


Thank you for your perfect answer. It’s clear at a glance