Making objects between camera and character transparent?

Hi,

I have a following scenario (approximate demo Babylon.js Playground )

  • character is moving on a navmesh via clicking, being tailed by a FollowCamera with obstacles between camera and the character obscuring the view

what I would like to achieve is to make the objects between camera and character transparent.

what I have tried:

  • attaching mesh to camera to check for collisions and make the colliders transparent

I tried to use ActionManager.OnIntersectionEnterTrigger, but I need to pass all the meshes as a parameter, which there are plenty of them, so it doesnt feel right to do it this way.
Is it somehow possible to check for all collisions by default, and then decide if that’s the mesh I want to affect?

There is not moveWithCollisions on FollowCamera (obviously) which I think would solve exactly this scenario.

Right now I’m resorting to changing camera.minZ to clip the obscuring objects, but that works suboptimally as there are always edge cases where it clips too much of the objects I want to keep, or too few of the objects I want to affect.

Is there any better solution how to deal with this? Thanks.

You could do a raycast (Havok is fastets) between camera and character. Everything hit that is not the character, is an obstacle.

2 Likes

You’ll have to look for a cheaper way, but it’s a simple function.

2 Likes