I got a weird bug. I’m tilting the camera left and right depending on sideways movement, id Style. I do it by using FInterpTo directly on the camera’s roll every frame using Tick. The problem is now, when I stop all movement, the camera doesn’t return all the way to the center. It’s weird because the function is still Ticking, and the camera’s Roll is returning all the way to 0, but it freezes slightly tilted. The moment I move (mouse or keyboard movement), it snaps back to normal.
Here is the function that sets the lean by interpolating the Camera’s roll between the center value (0.0) and the target value.
void AFPCharacter::UpdateCameraLean(float DeltaTime)
{
if (PlayerCamera)
{
if (!bIsMovingLeft && !bIsMovingRight)
{
TargetLean = 0.0f;
}
if (bIsMovingRight)
{
TargetLean = RightLean;
}
if (bIsMovingLeft)
{
TargetLean = LeftLean;
}
DefaultLean = FMath::FInterpTo(DefaultLean, TargetLean, DeltaTime, LeanSpeed);
PlayerCamera->RelativeRotation.Roll = DefaultLean;
}
}
The problem is that, the value is changing properly, but the viewport doesn’t center completely.
Here is an example. The White text is saying that the camera’s roll is set to 0, despite the camera still being tiled.
Now if I add any movement at all, either keyboard or mouse movement, it snaps back to the center.
Any ideas? I can post more info if needed.