#camera shake system
5 messages · Page 1 of 1 (latest)
Let me find it
Found it @marble flare
local TweenService = game:GetService("TweenService")
local Cam = workspace.CurrentCamera
local canShake = true
local intensity = 0.05
local maxIntensity = 0.2
local lastIncreaseTime = 0
function CameraEffect(cooldown)
if not canShake then
return
end
canShake = false
-- Gradually increase intensity every 4 seconds
if tick() - lastIncreaseTime >= 4 and intensity < maxIntensity then
intensity = intensity + 0.05
lastIncreaseTime = tick()
end
local shakeCFrames = {}
for i = 1, 3 do
local shakeAmount = Vector3.new(
intensity * (math.random() - 0.5),
intensity * (math.random() - 0.5),
intensity * (math.random() - 0.5)
)
local shakeRotation = Vector3.new(
intensity * (math.random() - 0.5),
intensity * (math.random() - 0.5),
intensity * (math.random() - 0.5)
)
shakeCFrames[i] = Cam.CFrame * CFrame.new(shakeAmount) * CFrame.Angles(shakeRotation.X, shakeRotation.Y, shakeRotation.Z)
local tweenInfo = TweenInfo.new(0.2, Enum.EasingStyle.Quint, Enum.EasingDirection.Out)
local shakeTween = TweenService:Create(Cam, tweenInfo, {CFrame = shakeCFrames[i]})
shakeTween:Play()
end
task.wait(cooldown)
canShake = true
end
game:GetService('RunService').Heartbeat:Connect(function()
CameraEffect(0.5)
end)```
Ye I took me a while to do that