So I made a camera shake but it’s not very smooth. I set the camera to a camera part when it happens so I can’t use humanoid’s camera offset, I also don’t want to use any modules like the EZ Camera shake module, how should I do this? Script:
for i = 1 ,3 do
for i = 1, 3 do
local x = math.random(-100,100)/1250
local y = math.random(-100,100)/1250
local z = math.random(-100,100)/1250
workspace.Camera.CFrame = workspace.Camera.CFrame * CFrame.Angles(x,y,z)
wait(0.11)
workspace.Camera.CFrame = workspace.Camera.CFrame * CFrame.Angles(-x,-y,-z)
end
wait(1.1)
end
1 Like
You could use TweenService to tween it.
1 Like
won’t I have to make like a bunch of variables for tweening though? and won’t it be laggy or something
1 Like
There are many ways you can increase smoothness but by far the easiest is:
Object.CFrame = Object.CFrame:Lerp(NewCFrame, Smoothness)
Where smoothness is 0 - 1 (ie 0.5) with lower values being more smooth.
Make sure to use a 60hz loop with RenderStepped to ensure it runs smooth.
1 Like
I thought Lerp function is deprecated?
1 Like
Not that I know of. There is no dedicated page for it but the CFrame wiki page does not list it as deprecated.
2 Likes
Ah, found it. CFrame:Lerp is not deprecated. Camera:Interpolate is. Two distinct things.
2 Likes