Here used SpringArmComponent to attach and control camera.
Camera rotation behavior provide ability to look at character from bottom and from above. It looks like rotation set between -90 and 90 degrees or something similar.
How can I constrain this to different values, to avoid problem from “screenshot” attachment, when camera cuts player’s mesh?
So first you will want to turn off “Use Controller Rotation”, next we are going to need to go into the eventgraph and tell the BP to clamp the camera rotation.
I have added an image that you can reference while following along with this mini-tutorial:
The simplest way to do this in the 3rd Person template is to start by getting the Camera Boom, then dragging off to get Transform > Relative Rotation. Break the relative rotation, so you can get Pitch and Yaw. Drag the two InputAxis events out into Add Float nodes. Add your Pitch from Break Rotator to your InputAxis LookUp. Add your Yaw to your InputAxis Turn. Separately Clamp both Add’s outputs. In the Clamps, you can set the angle to which you can rotate your camera. Drag off a Clamp and create a Make Rot node. Plug your Pitch clamp and Yaw clamp into their respective nodes. Add an Event Receive Tick. Drag off the execution and create a Set Relative Actor Location. Plug your Make Rot output into the New Rotation and your Camera Boom into Target.
In the image you may notice the InputAxis LookUp multiplies by -1 before adding. That will change it from inverted looking to standard. You can also see what my clamp Min and Max are; With that setup the camera can lean up and down slightly and turn to see a profile view on the character. Please let me know if you have any other questions.
I have looked into the node changes and there have been further alterations since my last post, making it invalid.
Lets approach this from another angle and see if it works better, because we are doing a “hacky” work around using Blueprint nodes.
Could you try creating a PlayerCamera Blueprint, then set the min and max rotation values in it’s defaults. Open your MyController Blueprint and in it’s defaults under Player Controller, set the Player Camera Class to the PlayerCamera you created earlier. Then PIE and see if that is a simpler fix for what you are trying to accomplish.
That is a known error that has since been resolved. Your rotations will not reset and jump like what you are seeing in Beta4 in the future release of the beta. I apologize for any confusion because of this.
Thank you for your question. Could you please give us a screenshot of your components where I can see your parenting setup and SpringArmComponent properties?
I am not sure if there is a better way or not, but the only way I have found is by using the “Get Player Camera Management” block, in there you will find two variables “View Pitch Min” and “View Pitch Max” if you set these manually prior to reaching the “Add Controller Pitch Input” this will restrict the camera movement between the min and max pitch.
Call it a manual clamp
to find the correct segments you will need to have “context match” unchecked.
the other way is to create a class from scratch and manually code the restriction in, for me the BP is the easiest way and it actually works!
Bear in mind I use Unreal Engine 4.10 (not sure if it is in the older versions or not)
How ever the principle is the same as for the YAW, see second screenshot.
This has helped a lot, however… This seems to only work on “world Relataivity” not local to the pawn… As in, when i try the same thing pointing the opposite direction my camera gets spun around. any way to use this but lock to the characters local forward vector? i’ve tried a few ways but can’t figure out what is going to work yet.
Not to necro an old thread, but none of these answers actually work. The closest was the Get Player Camera Manager suggestion but this only works with WORLD rotation not relative.
There has to be an easier way to clamp the rotation of a camera relative to the pawn.
Essentially I’m trying to create a First Person perspective with a body. I’ve added Aim offsets to the third person character and socketed the camera to the head bone and deleted the spring arm. Problem is, the Aim Offset requires Use Controller Yaw to be off but for the “First Person” effect to work, the rotation yaw has to be on, otherwise the camera can freely rotate in 360 degrees. The Pitch is clamped by default, why can’t there be an option to clamp the yaw?