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.