How do I setup camera collision?

I’m trying to make a 3rd person game, what is the best way/easiest to make the camera either go to first person when colliding with walls or overhead my character so that the camera doesn’t phase through.

cast a ray and put the camera on the hitposition and add some offset to make sure its a bitoff the wall/object.

check my resource: