Hello! I was wondering how I could possibly use Crazyman32’s camera shaker script. I’ve always used my own custom camera shake, and earlier today I got some feedback on my magic moves that I have been working on, saying that the camera shake is rather choppy and that I should try using EZ Camera Shake ported to Roblox
I’ve looked through all 3 module scripts and find it really confusing and would appreciate some help. Thanks!
I use this for certain explosions in my game. Basically i just have a bindable event that i can fire with certain parameters that allows me to have a camera shake with certain settings or the built in presets. I think there is more information on crazymans github regarding the modules but hopefully the below example might help you.
This is the code i use:
Shake.Event:Connect(function(Magnitude, Roughness, FadeIn, FadeOut)
local Magnitude = Magnitude or 1
local Roughness = Roughness or 1
local FadeIn = FadeIn or 0
local FadeOut = FadeOut or 1
local Shaker = CameraShaker.new(Enum.RenderPriority.Camera.Value, function(shakeCFrame)
Camera.CFrame = Camera.CFrame * shakeCFrame
end)
Shaker:Start()
if type(Magnitude) == "string" then
Shaker:Shake(CameraShaker.Presets[Magnitude])
else
Shaker:ShakeOnce(Magnitude, Roughness, FadeIn, FadeOut)
end
end)
Just FYI you’re introducing a data leak with that code. Every time a new shake event occurs, you’re creating a new shake event and starting it, but it’s never stopped.
Ideally, you should really only need one shaker instance, and you can layer shakes on it if needed. Maybe restructure it a little bit like this:
local Shaker = CameraShaker.new(Enum.RenderPriority.Camera.Value, function(shakeCFrame)
Camera.CFrame = Camera.CFrame * shakeCFrame
end)
Shaker:Start()
Shake.Event:Connect(function(Magnitude, Roughness, FadeIn, FadeOut)
local Magnitude = Magnitude or 1
local Roughness = Roughness or 1
local FadeIn = FadeIn or 0
local FadeOut = FadeOut or 1
if type(Magnitude) == "string" then
Shaker:Shake(CameraShaker.Presets[Magnitude])
else
Shaker:ShakeOnce(Magnitude, Roughness, FadeIn, FadeOut)
end
end)
All I did there was pull the Shaker initialization outside of the event.
Ohh yeah that was my bad, that was an old code snippet I had from an older file. The newer file had that updated in a similiar fashion to yours, thank you though for the heads up.