Download

Very confused on camera rotation/pitch

Hi all,

I’m trying to restrict camera movements when inside a vehicle and I’m having a difficult time grasping how the camera rotation works. I am printing the relative rotation pitch of my first person camera on every tick to try and understand this but I’m confused. My camera by default is rotated by -90,90,0 in relation to my mesh (I do understand the concept of relative vs world). My relative pitch when “looking straight ahead” is 90 as I would expect. When I move my mouse to look down, the pitch output goes down to 25. When I look up, it also goes down (as low as -5, because I’m not restricting the look up as much as look down). Why is this? Shouldn’t the pitch be increasing when I look up? When I rotate the Pitch of the camera in Viewport, it behaves the same way but I also see something really weird there; if I rotate it slowly, the Y value sometimes suddenly jumps to odd values like -400, what am I missing here?

Note that when in a vehicle, I am disabling use pawn control rotation and use controller rotation yaw, because I want to only control the camera separately from the pawn at that point and I am doing so by directly adding rotation to the camera with AddLocalRotation.

Hi man,
“My camera by default is rotated by -90,90,0 in relation to my mesh”
I would suggest you to place the camera under a scene component, and rotate the scenecomponent , so that the default rotation of your camera is 0,0,0 !

“When I move my mouse to look down,
the pitch output goes down to 25.
When I look up, it also goes down … Why is this?”
it should not !, take a look at this link https://forums.unrealengine.com/development-discussion/blueprint-visual-scripting/17130-fixed-camera-pitch
This will also show how clamp the value of the rotation

“suddenly jumps to odd values like -400,”
Sometimes when using rotation and quatersnions you can end up messing with gimbal lock and unpredictable result, but should not be this the case!

Thanks, I got what I was working on done by rotating my mesh’s head in the car instead of the actual camera which is attached to the head, so it’s working pretty well that way now (do you feel this is fine?) I do get some jitters on clients because I want the head position replicated, trying to figure a fix for that now. What I found is that because my camera was rolled 90 degrees both roll and pitch, it was causing the roll/pitch/yaw to all get switched around.