RenderStepped Probleme with FPS : 30, 240

  1. What do you want to achieve? Because of Roblox FPS unlocker, I wish all players could have the same bobbing no matter how many FPS

  2. What is the issue? I ran the camera script with using Roblox Fps Unlocker and the Intensity of the Bobbing is much more Stronger.

function viewmodelBob()
    if humanoid.MoveDirection.Magnitude <= 0 then
        -- no moving
    elseif humanoid.MoveDirection.Magnitude > 0 then
        bobCF = bobCF:Lerp(CFrame.Angles((math.cos(tick() * -8) * -0.1), (math.sin(tick() * -6) * 0.1), 0), 0.1)
    end
end

function viewmodelSet()
    for _, v in pairs(camera:GetChildren()) do
        if v:IsA("Model") then
            v:SetPrimaryPartCFrame(camera.CFrame * bobCF)
        end
    end
end

RunService.RenderStepped:Connect(function()
    if not self then return end
    if self.viewmodel then
        viewmodelBob()
        viewmodelSet()
    end
end)

Video of script running at 30 FPS

Video of script running at 240 FPS

Does this help?

local FPSTarget = 60 --Emulate the effect at this FPS

local function FixNum(Num:number, delta:number):number
	return Num * FPSTarget * delta
end

function viewmodelBob(delta:number)
	if humanoid.MoveDirection.Magnitude <= 0 then
		-- no moving
	elseif humanoid.MoveDirection.Magnitude > 0 then
		
		
		bobCF = bobCF:Lerp(CFrame.Angles((math.cos(tick() * FixNum(-8, delta)) * FixNum(-0.1, delta)), (math.sin(tick() * FixNum(-6, delta)) * FixNum(0.1, delta)), 0), FixNum(0.1, delta))
	end
end

function viewmodelSet()
	for _, v in pairs(camera:GetChildren()) do
		if v:IsA("Model") then
			v:SetPrimaryPartCFrame(camera.CFrame * bobCF)
		end
	end
end

RunService.RenderStepped:Connect(function(delta)
	if not self then return end
	if self.viewmodel then
		viewmodelBob(delta)
		viewmodelSet()
	end
end)

Also I suggest organizing the numbers into variables saying what they each will do.

1 Like

I figured out what your function was, but it’s not working
I tried to change the values but I found nothing conclusive
The viewmodel moves very easily in 240 fps and in 30 fps it moves enormously

I’m now noticing what I did wrong, though I think it will be difficult to solve this with how the bob works. I would suggest trying a simple sine camera bob as it would be much easier to make and would be easier to solve this issue with, rather than dealing with CFrames.
I can’t help much further with this as I don’t have a very good understanding of CFrames, sorry.

1 Like

OK I’ll try to see it, anyway thanks for trying to help me

1 Like

Maybe use Workspace.DistributedGameTime instead of tick() in this case? it increments independent of your framerate

Thanks to you it works I managed to make sure that no matter the FPS they see the same bob

local FPSTarget = 16

local function FixNum(Num, delta)
	return Num * FPSTarget * delta
end

function viewmodelBob(dt)
	if humanoid.MoveDirection.Magnitude <= 0 then
		-- no moving
	elseif humanoid.MoveDirection.Magnitude > 0 then
	bobCF = bobCF:Lerp(CFrame.Angles((math.cos(tick() * -8) * -0.1), (math.sin(tick() * -6) * 0.1), 0), FixNum(0.1, dt))
	end
end

function viewmodelSet()
	for _, v in pairs(camera:GetChildren()) do
		if v:IsA("Model") then
			v:SetPrimaryPartCFrame(camera.CFrame * bobCF)
			--updateCameraRecoil()
		end
	end
end

RunService.RenderStepped:Connect(function()
	if not self then return end
	if self.viewmodel then
		viewmodelBob(dt)
		viewmodelSet()
	end
end)
2 Likes

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.