This is honestly super cool and easy to use! I wanted to play around with it so I made a little view bobbing script that triggers the shake while walking. However, I wasn’t sure how to make a custom preset so I just edited the Rough Driving one.
(I didn’t know the music was on. I was listening to the Roblox copyright replacement music )
You can change the rotation and position influence with the custom shake methods
local Camera = workspace.CurrentCamera
local Shaker = CameraShaker.new(Enum.RenderPriority.Camera.Value+1, function(ShakeCF)
Camera.CFrame *= ShakeCF
end)
Shaker:Start()
Shaker:ShakeOnce(1, 1, 1, 1, Vector3.zero, Vector3.new(1,1,1)) -- Magnitude, Roughness, fadein and fadeout time and the last 2 Vector3 values are position influence and rotation influence
Shaker:StartShake(1, 1, 1, Vector3.new(0.5,0.5,0.5), Vector3.new(1,1,1)) -- same thing but for sustained shakes (like earthquakes) you can also just copy values off the presets and edit the influence
sup this is a cool module that i’ve been using for 4 years now really helps me with camera stuff
I want to share this fix for all who has fps problem.
The problem is if we change the fps, the camera shook more
My friend asked to sleitnick for fps fix and he replied to us.
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local RunService = game:GetService("RunService")
local CameraShaker = require(ReplicatedStorage.CameraShaker)
local CAMERA = workspace.CurrentCamera
-- Copied from example. Just added prevCamCf
local prevCamCf = CAMERA.CFrame
local camShake = CameraShaker.new(Enum.RenderPriority.Camera.Value, function(shakeCf)
prevCamCf = CAMERA.CFrame
CAMERA.CFrame = CAMERA.CFrame * shakeCf
end)
-- The fix:
-- Reset the camera on the first RenderPriority, before cam scripts run:
RunService:BindToRenderStep("ResetCF", Enum.RenderPriority.First.Value, function(dt)
CAMERA.CFrame = prevCamCf
end)
camShake:Start()
camShake:ShakeSustain(CameraShaker.Presets.Bump)
This method can be useable in this module and current latest shake module
Thanks to sleitnick for helping us!
If you want, you could also use RunService.Heartbeat
to reset the CFrame, since that runs after all the rendering is done too. Either work!
Is that will make lag? SLEOW grigjrtxzassad
I got a simpler solution for the high fps problem so basically what I did is changed the main module scripts line 154 and 155 to include " * dt * 70 " at the end. I don’t know if this is a perfect solution because is I just figured it out. The * 70 is the shake intensity over all you can change it to your liking
Just out of curiosity, what values did you use to get that.
If you are having fps problems (my monitor is 240fps), change line 155 of CamShake module fromlocal cf = self:Update(60) to local cf = self:Update(dt)
I’m having troubles with the example code in a fresh baseplate. The camera shake seems to additively be offseting the Camera CFrame causing it to shake intensely, and also causing the camera to stop in a different location to where it started when the shake ends.
The code I’m using (straight from the GitHub repo):
Code
local CameraShaker = require(script.CameraShaker)
local camera = workspace.CurrentCamera
local function ShakeCamera(shakeCf)
-- shakeCf: CFrame value that represents the offset to apply for shake effect.
-- Apply the effect:
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()
-- Apply explosion shakes every 5 seconds:
while (true) do
wait(5)
camShake:Shake(CameraShaker.Presets.Explosion)
end
I’m testing on 60fps, and so far I’ve tried render priorities 0 and 10,000 as well as RenderPriority.Camera to no avail.
Any help is greatly appreciated!
Im no genius but this module is like 7 years old, came here to ask if it still works but its probably broken (might be wrong tho dont take my word for it)
Please see a few posts above yours for the fix: EZ Camera Shake ported to Roblox - #158 by batin1597
Just saw that, this fixed it, thanks!
Hey, I’ve been trying to get this to work with a sustained shake, but everytime I run this code I get this error: ReplicatedStorage.Libs.CameraShaker:183: attempt to get length of a nil value
local CamShake = require(game:GetService("ReplicatedStorage").Libs.CameraShaker)
local ShakeRemote = game:GetService("ReplicatedStorage").Remotes.EnableCamShake
local function ShakeCamera(shakeCf)
workspace.CurrentCamera.CFrame = workspace.CurrentCamera.CFrame * shakeCf
end
local renderPriority = Enum.RenderPriority.Camera.Value + 1
local Shaker = CamShake.new(renderPriority, ShakeCamera)
Shaker:Start()
CamShake:ShakeSustain(CamShake.Presets.Earthquake)
Error comes from here:
function CameraShaker:ShakeSustain(shakeInstance)
assert(type(shakeInstance) == "table" and shakeInstance._camShakeInstance, "ShakeInstance must be of type CameraShakeInstance")
self._camShakeInstances[#self._camShakeInstances + 1] = shakeInstance --Here
shakeInstance:StartFadeIn(shakeInstance.fadeInDuration)
return shakeInstance
end
What am I doing wrong?
change CamShake:ShakeSustain(CamShake.Presets.Earthquake)
to Shaker:ShakeSustain(CamShake.Presets.Earthquake)
Holy, I was way to tired at the time of making this. Thanks!
Wrong, this module is really strong in keeping its functionality identical to how it was when it first came out, works perfectly fine with no errors.