CameraShaker is a small, lightweight, and customizable module made by Judash399! Camera Shaker has
- Stackable Shaking
- works with most Custom camera systems
- Can be customized to your needs.
You can find the download for the module here!
Examples
Here’s a simple system that shakes the camera whenever the player clicks:
Code
local UserInputService = game:GetService("UserInputService")
local CameraShaker = require(game.ReplicatedStorage.Modules.CameraShaker)
local shaker = CameraShaker.new(workspace.CurrentCamera)
UserInputService.InputBegan:Connect(function(input, processed)
if processed then return end
if input.UserInputType == Enum.UserInputType.MouseButton1 then
shaker:Shake(1)
end
end)
I dont have many examples but if you make something cool with the module let me know and I could feature you here!
Documentation
Fundementals
CameraShaker is a OOP camera shaking module. The module works by creating shakers which are attached to a camera and has a assortment of functions that can be called from them. To create a shaker run this code.
local shaker = CameraShaker.new([Camera])
Shakers have 4 functions you can call from them, the most common function is the shaker:Shake([intensity])
which basicly adds more shaking to the current shaker, this can stack so if you were to call this function twice it would be the combonation of both intensity values given.
whenever your done with a shaker you can call the shaker:Destroy()
function, please note this will stop all shaking imediatly.
If you disable auto updating you can call shaker:Update([DeltaTime])
to update the screen shake (this should be called once per frame)
You can call module.UpdateAllShakers([DeltaTime])
to Update all active shakers. (Thought this would be helpful for some people)
And finally if you call shaker:Stop()
you stop all shaking imediatly, (this is done by setting shaking intensity to 0) this may look slightly strange.
Adjusting Settings
The CameraShaker module has several settings that allow you to change how the camera shaking looks. These settings can be customized when creating the shaker object by passing in a table of settings, after the camera object when creating a shaker object.
Here are the settings and what they do:
-
DecayRate - How fast the shake fades away per second.
-
MaxIntensity - The cap for how much the camera can shake (Helps prevent camera from overshaking a lot!)
-
AutoUpdate - Uses a event to update the camera shake instaid of you doing it manually, helpfull if normal update system doesnt work for whatever reason.
-
ChangeShakeSpeedWithIntensity - Looks better in my opinion but if you want to turn it off you can. Does what the name implies, changes the shake speed with the Intensity
-
ShakeSpeedMultiplierX - Changes how fast the camera shakes on the X axis
-
ShakeSpeedMultiplierY - Changes how fast the camera shakes on the Y axis
-
ShakeDistanceMultiplierX - Changes how much shake intensity moves the camera on the X axis
-
ShakeDistanceMultiplierY - Changes how much shake intensity moves the camera on the Y axis
Update Log
Version 1.1.0
- Added the
UpdateAllShakers()
function - Minor Bug fixes
- Added Additional Type Annotations
- Additional Warnings/Error reports
Got feedback, suggestions, or found a bug? Feel free to reply below! I’d love to hear how you’re using CameraShaker!