How do you prevent the camera from going through walls?

I’ve tried looking at other questions, but they involve different situations.

Basically, I would like to know how to prevent my camera from going through objects, so that the player’s view doesn’t get obstructed. How do I accomplish this? Any way is appreciated.

By the way, I am creating a third person camera that follows an object around. I hope this information helps!

You can try firing a raycast from the player toward where you want the camera to be. If you hit anything, place the camera at that point instead. This does require anything the camera shouldn’t go through to have colliders.