I want to make a camera shake module for my project.
In this project, most of the time, the player will not have his own character. Still, I want to do camera shake, independently of whoever is playing (game is turn based). So this brings me to a big problem…
How do I handle the shakes while the Camera state is as default?
Most of the answers I have seen to this question rely mainly on the CameraOffset property of the Humanoid. My problem here is how can I make this for characters which are not the player’s? How would I handle this with an object that does not have a Humanoid?
You could just use EZ Camera Shaker, it is a powerful yet simple module. Just note that all the functions of the module are not entirely listed on the GitHub page and you should review the module’s code.
local function shakeCamera(length)
local startTime = tick()
while true do
if tick() - startTime >= length then break end
local x = math.random(-100, 100) / 1000
local y = math.random(-100, 100) / 1000
local z = math.random(-100, 100) / 1000
game.Players.LocalPlayer.Character.Humanoid.CameraOffset = Vector3.new(x, y, z)
workspace.CurrentCamera.CFrame *= CFrame.Angles(x / 100, y / 100, z / 100)
wait()
end
game.Players.LocalPlayer.Character.Humanoid.CameraOffset = Vector3.new(0, 0, 0)
end
game.ReplicatedStorage.Shakecam.OnClientEvent:Connect(function(t)
shakeCamera(t)
end)