Camera working differently in studio and in game

I have this camera breathing system, works perfectly fine in studio however when you join the actual game, you breathe wayyy to heavily.

Video of it in studio:

Video of it in the actual game:

As you can see, in the actual game, it looks like it bases itself off of fps, I’m not sure why it does this.

Higher the fps = heavier breathing and higher + lower camera movement
60 fps> = softer breathing and lower camera movement

Code:

RunService.RenderStepped:Connect(function(DeltaTime)
	local SwaySpeed = 0.4;
	local SwayIntensity = 0.3 + DeltaTime;
	local Smoothness = 0.2;
	
	local Tick = tick();

	local XValue = math.cos(Tick * SwaySpeed) * SwayIntensity;
	local YValue = math.sin(Tick * SwaySpeed) * SwayIntensity
	local ZValue = -10;

	if (Humanoid.MoveDirection.Magnitude > 0) then
		XValue = 0;
		YValue = 0;
		ZValue = 0;
	end

	local SwayCFrame = CFrame.new(Vector3.new(XValue, YValue, 0), Vector3.new(XValue * 1.1, YValue * 1.1, ZValue)) + Camera.CFrame.Position;
	
	if (IsFirstPerson()) then
		Camera.CFrame = Camera.CFrame:Lerp(SwayCFrame * Camera.CFrame.Rotation, Smoothness);
	end
end)

Note: I just want low-medium camera movement, not all that high movement stuff.

It appears your not using deltatime inside of your heartbeat function, so itll run differently on different frame rates

Edit: I see that you have added deltaTime to SwayIntensity, maybe try removing that and adding * DeltaTime after SwayIntensity in both the XValue and YValue

1 Like

Sorry for the late response, but thanks. I will try that right now!

I just noticed I left out of a line of code in it. The sway itself is fine now though.

New code:

RunService.RenderStepped:Connect(function(DeltaTime)
	local SwaySpeed = 0.4;
	local SwayIntensity = 0.3 + DeltaTime;
	local Smoothness = 0.2;

	local Tick = tick();

	local XValue = math.cos(Tick * SwaySpeed) * SwayIntensity;
	local YValue = math.sin(Tick * SwaySpeed) * SwayIntensity;
	local ZValue = -10;

	if (Humanoid.MoveDirection.Magnitude > 0) then
		XValue = 0;
		YValue = 0;
		ZValue = 0;
	end

	local SwayCFrame = CFrame.new(Vector3.new(XValue, YValue, 0), Vector3.new(XValue * 1.1, YValue * 1.1, ZValue)) + Camera.CFrame.Position;

	if (IsFirstPerson()) then
		Humanoid.CameraOffset = Humanoid.CameraOffset + (Vector3.new(0, (0.005 * math.sin(Tick - 0.225 * DeltaTime)), 0));
		Camera.CFrame = Camera.CFrame:Lerp(SwayCFrame * Camera.CFrame.Rotation, Smoothness);
	end
end)

The problem appears on the humanoid.cameraoffset line btw.