I am making an explosion camera shake that adjusts based on how close you are to the explosion, and I want to make this camera shake script I found smoother, I tried just subtracting the shakeintensity but it leads to inconsistent results because the shakeintensity is always changing based on the magnitude to the blast radius. Is there a simple solution to this?
This is the shake function
function Shaker.Shake(player, shakeIntensity, shakeTime)
local character = player.Character
local oldOffset = character.Humanoid.CameraOffset
if player.PlayerGui then
player.PlayerGui.HurtGui.ExplosionFlash.BackgroundTransparency = 0.7
TweenService:Create(player.PlayerGui.HurtGui.ExplosionFlash, TweenInfo.new(0.5), {BackgroundTransparency = 1}):Play()
end
for i = 0, shakeTime do
local offset = Vector3.new(math.random(-1,1), math.random(-1,1), math.random(-1,1))
character.Humanoid.CameraOffset = character.Humanoid.CameraOffset:Lerp(offset, shakeIntensity * 0.25)
if shakeIntensity > 0 then
shakeIntensity = shakeIntensity - 0.03
end
TweenService:Create(character.Humanoid, TweenInfo.new(0.01), {CameraOffset = oldOffset}):Play()
RunService.Heartbeat:Wait()
end
TweenService:Create(character.Humanoid, TweenInfo.new(0.01), {CameraOffset = oldOffset}):Play()
end
Also I do NOT want to use EZ camera shaker.