-
I’m trying to use the EZ Camera Shake module(Camera Shaker - Roblox), and shake the screen while I’m render stepping a camera angle that keeps the camera watching the character at a certain angle.
-
The problem is, it keeps the camera angle there but it doesn’t shake the screen. I’m assuming it’s because it’s trying to shake the screen while constantly render stepping a camera angle and it can’t do both at the same time.
-
So I tried, making a value that waits for the continuous render stepped to stop while the camera shake is happening but that didn’t work because I’m trying to keep the camera shaking while following the original camera render stepped.
I’m wondering how would I go about this, to make it work?
Here is the code below.
local CameraShaker = require(script:WaitForChild("CameraShaker"))
local camShake = CameraShaker.new(Enum.RenderPriority.Camera.Value, function(shakeCFrame)
Camera.CFrame = Camera.CFrame * shakeCFrame
end)
camShake:Start()
local isShaking = false
function shakeScreen()
if isShaking then
return
end
isShaking = true
coroutine.resume(coroutine.create(function()
for i = 1, 100 do
camShake:Shake(CameraShaker.Presets.SemiAggressiveBump)
wait(2)
end
isShaking = false
end))
end
function onRenderStep()
if Player.Character then
if not isShaking then
local DOWN = Vector3.new(0, -1, 0)
local XR, YR, ZR = tonumber(screenGui.XR.Text), tonumber(screenGui.YR.Text), tonumber(screenGui.ZR.Text)
local X, Y, Z = tonumber(screenGui.X.Text), tonumber(screenGui.Y.Text), tonumber(screenGui.Z.Text)
local cameraOffset = Vector3.new(X, math.clamp(Y, 5, 50), math.clamp(Z, 10, 55))
local rootPart = HumanoidRootPart
Camera.CFrame = CFrame.new(rootPart.CFrame.Position + cameraOffset, rootPart.CFrame.Position + DOWN) * CFrame.Angles(math.rad(XR), math.rad(YR), math.rad(ZR))
end
end
end
Connections.Cam = RunService.RenderStepped:Connect(onRenderStep)
coroutine.resume(coroutine.create(function()
shakeScreen()
end))