camera collision issue

So, I made a simple landwalker to test how collisions work and one problem I ran into was the camera collision.
I made a collision sphere for my avatar and it works fine but the camera still goes through the walls. I tried adding a collision sphere to the camera but when i do that, every time it hits a wall the camera moves like this:

https://i.imgur.com/gmElqTd.gif

Is there any way I could solve this issue?