Limit camera/object rotation

Hi, anybody knows how to set boundaries for pitch and yaw for mouse input? I want to control came after using set view target.

I was trying to use clamp and clamp angles with min and max values but that didnt work.

Thx for help.

there are several ways to approach this…

the issue you are having is in using the Add Relative Rotation. Even if you clamp the input float, it will still “add” to relative rotation.

The simplest way with your current setup would be to add the following to Tick > Get Relative Rotation > Clamp > Set Relative Rotation

Hi, thanks for the answer, but i need to say that im a little bit confused.
Im sending my current blueprint setup which is obviously wrong and i need guidance.

My main problem with Set Relative Rotation is that it points my camera to “random” direction.

I’d have thought this would work, but I’d just run it off Tick… snip the connector between Add and Set relative rotation and see if this works

BTW if your RT Camera component is a Spring Arm component… this may not work… Spring Arm components don’t always work well with relative rotation because relative rotation is overridden by Use Pawn Control Rotation and (maybe) Inherit Pitch / Yaw / Roll. So let us know if it’s a Spring Arm component and a different approach may be better

Hey, I have found almost perfect solution but it works only with Y (Pitch). When im trying to clamp Z my camera is turning 45 degree however clamping is working on both values Y and Z.

When im limiting only Y and pluging Z straight from rotator to relative rotation everything is perfect so the problem is somewhere in Z space.

Its just camera component but meaby in this case it should be attached to spring arm.

… the first thing I’d try is using Clamp (angle) instead of Clamp (float)…

There is no difference between angle and float my camera is still rotating to the right.

Solved! For correct values use print node connected to event tick to print out yaw/pitch values per frame. Then check on what range you get the proper result.

3 Likes

Perfect Way