Make trees non transparent on camera touch

Hello, I added colliders to the trees, but I hae one more problem that I cant solve. If I touch the tree with my camera, it becomes transparent. I would like to make it soft, like camera wouldn’t go trough that. Also, something similiar is becoming with terrain. Sometimes my camera (doesn’t matter if that’s 1st or 3rd person) go under the surface and just like that. Is there some way to prevent this ?

What you’ve referred to is called “clipping”. The camera has to have a cutoff point, so that it doesn’t try to render anything that is behind it. Usually, this isn’t a problem, but you will see artefacts like this when your camera intersects with the object.

You can solve this in two ways. The most common solution is to add a collider to your camera. This will mean the camera moves around objects, and will stop it from sinking inside them. The second and more complex solution is to have objects “fade out” when they get near the camera. You can do this with shaders, but you will probably also need to swap the shaders out as the get near the camera, in order to make use of the depth buffer, and for performance.