Camera Shake exaggerated with high FPS

I am prototyping a horror game at the moment, and I want an effect where the camera shakes when the monster is near you. To achieve this, I am using the EZ Camera Shake ported to Roblox by @sleitnick. Original post to that is here: EZ Camera Shake ported to Roblox

However, the desired effect only works as intended in studio, with 60 FPS. This function is not connected to any FPS-related events, such as .RenderStepped or .Heartbeat. It fires once every ~0.5s at the most.

The cameraShake instance setup is as follows:

local player = game.Players.LocalPlayer
local character = player.Character
local humanoid = character.Humanoid
local camera = workspace.CurrentCamera

local function ShakeCamera(shakeCf)
	camera.CFrame = camera.CFrame * shakeCf
end

-- Create CameraShaker instance:
local renderPriority = Enum.RenderPriority.Camera.Value + 1
local camShake = CameraShaker.new(renderPriority, ShakeCamera)

-- Start the instance:
camShake:Start()

And each time the actual shake is called:

local magnitude = ((1/distance) * 25)
local fadeInOut = 1 
camShake:ShakeOnce(magnitude, magnitude * 3, fadeInOut, fadeInOut)

The issue I am having is simple. When I launch the game through my Roblox Player, I get ~300-400 FPS, and the camera shaking appears amplified by a lot. I tried to skim through the CameraShake modules code, but it looks like * deltaTime shows up everywhere that it needs to.

[Edit]: One thing to note, I tried printing the magnitude, distance (between me and the monster), and the fadeInOut to compare the values between 60 and 300-400 FPS. The difference is negligible.

4 Likes

Did you find a fix for this? or can anyone else help?

you should have a task.wait() with .RenderStepped:Wait() so theres frame delay in your CameraShaker module

This is the only thing that I could find related to renderstep, you think this would work?

function CameraShaker:Start()
	if (self._running) then return end
	self._running = true
	local callback = self._callback
	game:GetService("RunService"):BindToRenderStep(self._renderName, self._renderPriority, function(dt)
		profileBegin(profileTag)
		local cf = self:Update(dt)
		profileEnd()
		callback(cf)
		task.wait() -- what i added
	end)
end

in that case you can just do RunService:RenderStepped:Wait() see if that worked

sorry for bump, did you ever find a solution to this?

1 Like