Download

Restricting pitch and roll angles (non-linear interpolation)

Hello,

This question was asked many times and some things are still not clear to me.
In my game I am trying to implement helicopter/hover vehicle movement. So at this point I am working on Roll and Pitch angles. When a player presses A or D then vehicle strafes to the left or right. I want the vehicle to slightly roll at this moment. I kind of implemented this:
strafe1.png
see when the vehicle starts to roll, the angle interpolates smoothly. And here:
strafe2.png

I’ve done this using advice from Spoof on this forum page: https://forums.epicgames.com/threads/933295-What-are-the-do-s-and-don-t-s-of-Lerp
That worked for me fine because when the player presses A or D, I know exactly what the target angle is going to be. (-max roll, 0 or +max roll)

But then I got to pitch or look up logic. And this is what confused me. The problem is that movement is continuous in its nature. The players moves the mouse and that defines the pitch speed. At this point I am using the 3-person Flying sample project. There pitch speed smoothly interpolated with FMath::FInterpTo function. But there is not limit for pitch angle. I implemented it with FMath::ClampAngle which works but not how I want. If you look at the graph on the second screenshot I attached you would see that the vehicle reaches its maximum roll angle smoothly but in case of FMath::ClampAngle the pitch speed goes to zero instantly which is visible and does not look good to me.

Could you advice what I could do with pitch angles?