Clamp Control Rotation - Third Person Shooter

Hello Everyone!

I’ve been searching for days trying to find a solution for this but have had no success via my own experimentation nor found anything online which is with respect to my particular functionality.

So, I’m prototyping the mechanics for a third person shooter and am using the axis input from the Y axis of the mouse to control the camera (via control rotation).
I would like to restrict/clamp the pitch of the control rotation between roughly 60 degrees and 240 degrees, in order that the player cannot aim directly up (90 degrees), nor down (270 degrees).

Below is my current blueprint script for the axis input for the control rotation for the sake of clarity:

Is it possible to clamp the pitch of the control rotation, and therefore the camera? And if so, how can I do this?

Thanks all!

Just in case anyone is still reading this. One way to do it is the following:

Since the pitch (up and down rotation) is ranged from 270-360 // 0-90, the above solution will clamp the total look up and down angle to 290-360 // 0-30. Target of “Set Control Rotation” is the controller. You can run this event on tick, but a better way (imho) would be to tie it to the “look up” input axis mapping.

Hope this helped anyone

1 Like