I’m currently making a camera-shake module for my game. I would like to pass through an intensity
argument in the function to adjust the intensity of the shake, but my code relies on BindToRenderStep to work.
Is there a way to pass through arguments in BindToRenderStep?
My code:
function module.initCameraShake(intensity)
local plr = game.Players.LocalPlayer
local char = plr.Character or plr.CharacterAdded:Wait()
local hum = char:WaitForChild("Humanoid")
local now = tick()
local bobbleX = math.cos(now * 9) / 2--6
local bobbleY = math.cos(math.sin(now * 12)) / 2--3
local bobble = Vector3.new(bobbleX, bobbleY , 0) * 5
hum.CameraOffset = hum.CameraOffset:Lerp(bobble, .1)
end
function module.shakeCamera(bool)
if bool == true then
runService:BindToRenderStep("CameraShake",Enum.RenderPriority.Camera.Value + 1,module.initCameraShake)
else
runService:UnbindFromRenderStep("CameraShake")
end
end