Download

Best Way to Cap mouse-controlled Turn Speed

I am using the FPS Tutorial as a base for a third person game (just substituted first person for TPS with a spring arm camera) and I need to clamp the rotation speed controlled by the mouse based on a float value. What is the best way for me to do that in C++?

In your Tick function:


DeltaRotation.Yaw = FMath::Clamp<float>(MouseInput.X * TurnRate, -MaxTurnRatePerSecond * DeltaTime, MaxTurnRatePerSecond * DeltaTime);
DeltaRotation.Pitch = FMath::Clamp<float>(MouseInput.Y * TurnRate, -MaxTurnRatePerSecond * DeltaTime, MaxTurnRatePerSecond * DeltaTime);

Thanks a lot.