Method 1: Using Spring Arm Component (Recommended for Third-Person Cameras)
- Select Your Character or Camera Actor:
- In the Blueprint of your character, find the camera component and the Spring Arm component attached to it.
- Adjust the Spring Arm’s Rotation Limits:
- In the details panel of the Spring Arm, you can modify these properties:
- bEnableCameraRotationLag: If enabled, it helps to smooth the camera’s rotation.
- Camera Rotation Limits: This is where you can limit the camera’s pitch and yaw.
- In the details panel of the Spring Arm, you can modify these properties:
- Blueprint Scripting for More Control:
- If you need more specific rotation limits, you can script it in the Event Graph using the
Player Controller
‘sSet Control Rotation
and limit the pitch/yaw manually:- First, get the current
Control Rotation
using theGet Control Rotation
node. - Then, manipulate the pitch and yaw values (for example, clamping the pitch between -60 and 60 degrees).
- Finally, set the modified rotation back using the
Set Control Rotation
node.
- First, get the current
- If you need more specific rotation limits, you can script it in the Event Graph using the
Example Blueprint Script:
plaintextCopy codeEvent Tick
Get Control Rotation
Break Rotator
Clamp Pitch (Between -60 and 60)
Clamp Yaw (Between -180 and 180)
Make Rotator (Clamped Pitch, Clamped Yaw, Current Roll)
Set Control Rotation (Modified Rotator)
Method 2: Limiting Camera Rotation Directly (for First-Person or Custom Cameras)
If you want to limit the camera’s pitch and yaw directly:
- In your character blueprint, get the Player Controller and call the
Get Control Rotation
node. - Modify the Pitch and Yaw components as needed (clamping them).
- Use the
Set Control Rotation
node to apply the new limited rotation.