First Person + Locked Y Axis improvements

Hello, this is my first time posting so I hope this has been formatted correctly.

I have been attempting to make a first person shooter alike to that of Doom 64, my first goal is to make the camera through a local script in starterplayerscripts force the camera to not be able to look up or down, this has worked decently but I noticed that there was still the slightest shake in the Y axis whenever I moved the mouse.

As I am attempting to recreate the feel of an old n64 game, I am also displacing the camera to be a fair amount of studs away from the character, which means moving the camera up and down will be much stronger due to the pivot offset. As a result the camera is still very shakey as it attempts to correct itself to being at a 0 degree angle, thus not truly locking itself onto the Y axis.

I would really appreciate anyones advice on how I can better improve this code to be able to absolutely minimise the amount of shaking/jittering on the Y axis, as it seems that truly locking the Y axis in first person is simply impossible.

  • Calculates how offset the camera is on the Y axis from 0 and attempts to get a value that would cancel it out back to 0
  • I have attempted every form of renderstepping/presimulation, either breaks or does not improve situation
  • I want to learn if there is a way to prevent the jittering when the mouse attempts to move up and down the y axis, it is extremely nausiating and does not replicate how camera types like orbit handle the Y axis (I cannot use these cameratypes as they are incompatible with first person)
local Plr = game.Players.LocalPlayer
local Chr = Plr.Character or Plr.CharacterAdded:Wait()
local RunService = game:GetService("RunService")
local Camera = workspace.CurrentCamera

Camera.FieldOfView = 70

RunService.RenderStepped:Connect(function()
	
	for _, part in Chr:GetDescendants() do
		if part:IsA("BasePart") then part.LocalTransparencyModifier = 0 end
	end
	
	
	local YAngle = Camera.CFrame:ToOrientation()
	local CorrectedAngle = 0

	CorrectedAngle = 0 - YAngle ---- This is supposed to give me a value that would set the CFrame angle back to 0
	
	print(CorrectedAngle) -- Depending on how fast I move the mouse, it ranges from 20/-20 to 0.02/-0.02 etc. I want it to be absolutely 0
	
	Camera.CFrame *=    CFrame.new(0,0,20) * CFrame.Angles(CorrectedAngle, 0, 0) -- player can only look left/right
end)

1 Like

Not necessary for me to add onto the context but the reason I am having the players camera be offset by 20 studs is to render the surroundings more flat, I am ultimately trying to recreate the 2.5D likeness in these games. By having the FOV decreased to then recreate the default FOV 70 and 0 stud displacement where the camera would usually be.
After that I will be learning how I can simulate Y-shearing (which will mean recreating how the camera receives signals of the mouse moving up/down)