Camera Transparency

How can I make my camera to make objects 50% transparent when it goes right in front of something. Like in many games the objects gets transparent so the person can see the character.

Raycast directly from the camera forward. If it hits an object, access that object’s renderer component, go to color and set the alpha channel to 0.5

Obviously you’ll want to use collision layers to avoid turning your character or terrain or whatever you don’t want transparent.