Camera Collison

void LUpdate_CameraMovement()
{
if(networkView.isMine)
{
if(c.canControl)
{
c.x += mouseX * mouseXSens;
c.y -= mouseY * mouseYSens;

	   		c.y = V_LookAngle;
			
			c.cameraRotationPoint_current = Vector3.MoveTowards(c.cameraRotationPoint_current, IS_AIMING ? (IS_CROUCHING ? c.cameraRotationPoint_crouching_aiming : c.cameraRotationPoint_aiming) : c.cameraRotationPoint_normal, Time.deltaTime * c.speed_offsetChange);
			c.cameraPositionOffset_current = Vector3.MoveTowards(c.cameraPositionOffset_current, IS_AIMING ? (IS_CROUCHING ? c.camera_PositionOffset_crouching_aiming : c.camera_PositionOffset_aiming) : c.camera_PositionOffset_normal, Time.deltaTime * c.speed_offsetChange);
			
			c.cRotation = Quaternion.Euler(c.y, c.x, 0);
	        c.cPosition = c.CalculateCameraPosition(c.cameraRotationPoint_current, c.cameraPositionOffset_current, c.cRotation);
			c.transform.position = c.cPosition;
			c.transform.rotation = c.cRotation;
		}
	}
}

This is a mouse orbit script to orbit the camera around your player when you move your mouse around. The only problem with it is it allows the camera to go through walls, what do I do to fix this?

the c.CalculateCameraPosition(), whatever it currently does, should also contain a part where it casts a ray or better a sphere from the source point to the player, and if something is hit, it can return the hit point, else the otherwise calculated position.