¿How can I limit camera Horizontal rotation?

Hi everyone.
I need help to limit horizontal rotation.
I don’t want the camera to rotate 360 ​​degrees. I want that rotate 180 maybe or less.
If you can, be specific about what I can do. Please. Thank you.

Hello,

Assuming you are using a mouse to control the rotation of the camera based on the First Person Shooter tempalte, you can do the following:

Open the FirstPersonCharacter blueprint.

Navigate to the section with the comment “Mouse Input” in the EventGraph

Insert a select node in between the InputAxisTurn event and AddControllerYaw function and set the index class to Boolean,

Then get the character’s forward vector in world space. Multiple this vector by a constant vector of (1,1,0) so that the next step ignores whether the player is looking up or down. Also prepare a literal vector with a value of (1,0,0). Then get the Dot product of the two vectors, this will provide you with a a float value between -1 to 1, -1 means the player is facing in the complete opposite direction from the one you specified, where as 1 means the player is facing exactly forward. This is very convenient in our case, because we can just multiply this new float value by the original axis value, and place it into the “false” input of the select function.

If you start testing now, you’ll see the effect is already almost working, except, it also slows the camera down if you try to look back in the correct direction. This is where the select statement comes into play. We’ll check whether the Forward Vector is on the left of the player, or on the right of the player, depending on the answer, we’ll use the original axis value, so as not slow down the camera rotation.

To do this, get the sign of the Y component of the forward vector, and get the sign of the InputAxis, if they are not the same, then use the original InputAxis.

Try running it now. You should be able to turn left and right, but not behind you.

Or you can use the Camera Manager that does all that and more:

From what you posted it’s unclear what you’re trying to achieve, though. Is this for the player, are you using Controller Rotation for this… ?

If you do not want to override the Camera Manager, you can get the default and set View Yaw Max to what you need.

Ah, that seems way more efficient than modifying the blueprint. I’d defer to Everynone’s solution.

It worked for me, thank you!

Should work too, thanks for you comment. I’m trying this for the player.