Hello all! I am working on some fancy camera movement, and I ran into problems after disabling “Use Pawn Control Rotation”. When disabled and I adjust the pitch using the mouse, the camera seems to be rotated as if it’s origin was the very back of the camera component gizmo. When it’s enabled, the camera seems to be being rotated as if it’s origin is the center of the gizmo which is what I want. Here are two videos along with some the code to help explain the issue better:
if (Controller == nullptr || !AdvancedCameraMovement)
return;
if (!GetCharacterMovement()->IsMovingOnGround() || !bIsMoving || bIsCrouching)
{
Camera->SetRelativeLocation(FMath::VInterpTo(Camera->RelativeLocation, FVector(0, 0, BaseEyeHeight), delta, 10));
Camera->SetRelativeRotation(FMath::RInterpTo(Camera->RelativeRotation, FRotator::ZeroRotator, delta, 10));
return;
}
FVector velocity = FRotationMatrix(GetControlRotation()).InverseTransformVector(GetVelocity());
float bobZ = FMath::Sin(Delta * (velocity.Size() * (PI / 180)) * 2) * (bIsSprinting ? WalkingAmplitude * 2 : WalkingAmplitude);
Camera->SetRelativeLocation(FMath::VInterpTo(Camera->RelativeLocation, FVector(0, 0, BaseEyeHeight + bobZ), delta, 20));
Camera->SetRelativeRotation(FMath::RInterpTo(Camera->RelativeRotation, FRotator(0, 0, velocity.SafeNormal().Y * (bIsSprinting ? LeanAmount * 2 : LeanAmount)), delta, 10));
In both videos, I start by moving to show which one has my custom camera movement, then I look down to show the difference. Notice that with “Use Pawn Control Rotation” set to false, the camera appears to be closer to the ground when I look down. Also, with “Use Pawn Control Rotation” set to true, I cannot adjust the roll of the Camera. Any help? How would I fix this? Is there a better way to do this? Thanks!