CameraOffset flickering and not working in cars

not gonna write an entire essay because id prefer not to waste yalls time so here’s the video:


code (localscript in startercharacterscripts):

game:GetService('RunService').RenderStepped:Connect(function()
	if (head.CFrame.p - camera.CFrame.p).Magnitude < 1 then
		humanoid.CameraOffset = Vector3.new(0,0,-1)
	else
		humanoid.CameraOffset = Vector3.new(0,0,0)
	end
end)
1 Like

You’re only changing the offset, not the current zoom of the camera, If you’re trying to prevent First Person there’s a setting in the StarterPlayer called CameraMinZoomDistance, you can increment that to prevent first person.

sorry for the misunderstanding, i want to change the camera offset to vector3.new(0,0,-1) when they go first person, since that makes driving the car look more realistic, but my problem is in the video

…also what is zoom

Ah, that happens because the magnitude changes depending on where you’re looking, if you’re looking down it’ll break as the magnitude is going back in forth of more than 1 and 0(happens because you’re only measuring the distance between head and camera, the flaw is the camera wouldn’t always have the same magnitude as the head if camera is moving), and you’re not doing the best way to get what is the current camera zoom I recommend trying this.

game:GetService('RunService').RenderStepped:Connect(function()
	if (camera.CFrame.Position - camera.Focus.Position).Magnitude < 1 then
		humanoid.CameraOffset = Vector3.new(0,0,-1)
	else
		humanoid.CameraOffset = Vector3.new(0,0,0)
	end
end)

That regardless of the distance between the head and camera it’ll still have the same value despite their distance.

1 Like

that fixes the flickering but not the car glitch

Not too sure about the car, but you could try finding a better approach instead of using loops, currently 12 am here and I’m not that knowledgeable in camera manipulations. I recommend try changing the CameraOffset while in the car see if its the script that has problems.

humanoid.CameraOffset = Vector3.new(0,0,-5) --Try bigger numbers to see noticeable results.
If nothing changes then the problem might be somewhere around the seat colliding with the camera?, or being an roblox bug overall not sure.

1 Like