November 23, 2019, 1:51am
Normally in first person, players may look 90 degrees up and down. Meaning, they can look directly above them at the sky, and directly below them at the floor.
My question: Is it possible to limit their first person camera on the vertical axis? Meaning, instead of looking 90 degrees up/down, they could only look maybe 60 degrees up/down.
I have looked around the DevForum, and have found no solutions. I am working on a game that may require the player’s vertical range to be limited. Thanks.
Yes, this is definitely possible!
If you’re using the core camera scripts, you can clone them into
StarterPlayer.StarterPlayerScripts and edit
PlayerModule.CameraModule.BaseCamera, lines 19 and 20:
These control the maximum and minimum angles on the Y axis that the player can look. In this case, I changed the values from
40, respectively. This put a cap on how high/low I could look.
Is there a way to do this but with the horizontal axis? I’m trying to limit how far to the side a player can look when in first person. Sorry if that doesn’t make sense.
It is! You will need to fork & tweak the corescript
BaseCamera module with your own clamps.
Yeah I figured that would be the case but I can’t seem to find where the variables for that are stored. Sorry for the trouble.
There probably aren’t any, you’ll need to add your own behavior.
Oh dear. Okay. I honestly don’t know how to do that but I will try to figure it out. Thanks!
Use the existing code in the module as a reference! The math for the horizontal axis clamp will be a bit different, but it should be largely the same as what the vertical axis uses.