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:

pg: https://www.babylonjs-playground.com/#ZI9AK7#1803

1 Like

A simplified approach which may be of help to you https://www.babylonjs-playground.com/#ZI9AK7#1804

Your PG + rayHelper to show ray https://www.babylonjs-playground.com/#ZI9AK7#1805

This may also help Mesh Picking | Babylon.js Documentation

4 Likes

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