how do i lock the View Yaw in First Person Camera? (Free Look Mode)

Hello!

So i made a First Person Mode, it does work and i also added a Free Look Mode where you can tilt your head and look around without changing movement directions

The problem is that i can look behind myself (360°) and therefor would break the characters Neck…

I tried setting it up with “Set View Yaw max/min” to lock the view 90° to the left and 90° to the right directly.
It works, it locks in the degrees - but he doesnt take the characters Mesh or any other component which defines the chars direction in world space…

It instead locks the Yaw in the Axis of the World, so no matter where iam facing with my character, it always locks the camera in the same axis of the world… so i need to somehow get it to use the Axis of my Character, but i dont know how to… i tried so many things but i just cant seem to get it to work …

help? :grimacing:

Here is an Imgur Link to a short video showing the problem (if its not allowed to post pls feel free to delete it@moderators):
Lock ViewYaw in FirstPerson “Free Look” Mode
sry for the quality, Imgur renders it lower
(In the second part of the Video i edited something in the blueprint, to try to get the Mesh rotation, didnt work at all)

Picture of Blueprint

If you are using a spring arm it will react with collision. So simply adding a camera as a child to the moving object and not returning the YAW when moving the controller / mouse, should suffice.

Hey @SkalOrn! Welcome to the community!!!

So one of the first things I noticed was this.

image

You have Yaw - (-90) which would just be 90, same as the above “Add float” Node.
Other than that, you should try using a clamp node!
image
This can be used to bar addition over a certain point and subtraction under a certain point to keep your camera from going too far from it’s desired angle set :slight_smile:

Give that a try and if you need any extra guidance just let us know!

Iill try that out in the next days and reply! :slight_smile: thank you very much

hi SkalOrn, welcome to the communty :slight_smile:

You can also set your pitch, yaw and roll limits in the PlayerCameraManager, which is a little BP you (optionally) add to your PlayerController.

To set limits on-the-fly (like when you enter freelook mode). You’d get a reference to your PC>PCM>Set (pitch/roll/yaw)

OOOH @DavidOConnor Good call! I forgot about the PlayerCameraManager!

@SkalOrn Definitely use that since you’re giving your camera special use cases, it’s a life saver!

1 Like