Camera Obstacle Avoidance

I want to create a pretty basic obstacle avoidance system for my third-person camera. I just want to know the math involved in doing that, should be able to implement it to my camera system I just have no idea where to start. Well, I have a basic idea of where to start I just don’t know the math involved to getting the camera to rotate away from where a sphere trace hits.

I was able to get the effect I want by sending out a sphere cast, getting the hit point. Doing a dot product between the right vector of the camera and the “HitResult.Normal” from the camera. Checking if its left or right by checking if it’s positive or negative, then subtracting by (-90, and 90)

			if (HitResult.bBlockingHit)
			{
				const float RightDot_S = FVector::DotProduct(CameraRight, HitResult.Normal);


				if (RightDot_S > 0.0f)
				{

					RotationOffset = -90.0f; // Rotate away from the right side
				}
				else if (RightDot_S < 0.0f)
				{
					RotationOffset = 90.0f; // Rotate away from the left side
				}

				FRotator ControlRotation = PlayerController->GetControlRotation();

				float newRotationYaw = ControlRotation.Yaw + RotationOffset;


				const float InterpolatedYawRotation = FMath::FInterpTo(PlayerController->GetControlRotation().Yaw, newRotationYaw, FApp::GetDeltaTime(), CameraAvoidanceSpeed);
				ControlRotation.Yaw = InterpolatedYawRotation;
				PlayerController->SetControlRotation(ControlRotation);
			}