Here when this functions starts by the timer GetWorldTimerManager().SetTimer(CameraResetTimer, this, &ADefaultPlayerController::CameraRotationReset, 0.01f, true); it won’t stop because it doesn’t update the camera’s rotation (as you see above, it needs to stop when camera rotation is 0). If I set the rotation by manually within editor at runtime, algorithm continues to work as expected and gets stuck again at this interp.
I’m transfering this code from BP to C++ and the BP version works perfectly:
And that is not only place I use RInterpTo. There is one more of it which rotates the camera and it works fine.
What I tried:
-There is nothing that interrupts i.e forces back the camera when it should go to 0 rotation.
-Tried both FMath/UKismetMath and RInterpTo/RInterpToConstant.
-AI suggested that there could be a math problem so normalize your rotation before calculations, didn’t change anything.
-Revised the (whole) code several times, it’s same as the BP one.
All code is in the Player Controller and there is no code (in another class) that alters camera or any other related component.
Oh yes the problem was about delta seconds, a rookie mistake. I was passing the delta to functions as reference directly from Tick. When I checked it inside that reset function found out that something has corrupting the delta, it had some random negative values. I’ve changed the code to pass delta as copy and problem fixed.