Adding camera shake while simultaneously tweening camera?

Hello! I was experimenting with camera manipulation and tweening in an attempt to recreate a camcorder-style cutscene for my game. Essentially, I wanted to smoothly transition the camera from one point to another while incorporating a realistic shake, simulating the effect of someone holding the camera and walking.

However, when I tried to add a camera shake effect to my script, I encountered a challenge – only one aspect of the script seemed to work at a time. Basically, if I add a camera shake effect, the tweening part of the script doesn’t work, and vice versa. It seems you can’t change the CFrame of the camera while tweening.

I searched the devforum but found only one post related to my issue. Unfortunately, the suggested solution did not help fix my problem.

local ts = game:GetService("TweenService")
local ti = TweenInfo.new(0.4, Enum.EasingStyle.Linear, Enum.EasingDirection.InOut, 0, false, 0)

wait(2)
game.Workspace.CurrentCamera.CameraType = Enum.CameraType.Scriptable
game.Workspace.CurrentCamera.CFrame = game.Workspace.Cam1.CFrame

ts:Create(game.Workspace.CurrentCamera, ti, {CFrame = game.Workspace.Cam2.CFrame}):Play()
wait(math.random(0.1, 0.5))
ts:Create(game.Workspace.CurrentCamera, ti, {CFrame = game.Workspace.Cam3.CFrame}):Play()
wait(math.random(0.1, 0.5))
ts:Create(game.Workspace.CurrentCamera, ti, {CFrame = game.Workspace.Cam4.CFrame}):Play()
wait(math.random(0.1, 0.5))
ts:Create(game.Workspace.CurrentCamera, ti, {CFrame = game.Workspace.Cam5.CFrame}):Play()
wait(math.random(0.1, 0.5))
ts:Create(game.Workspace.CurrentCamera, ti, {CFrame = game.Workspace.Cam6.CFrame}):Play()
wait(math.random(0.1, 0.5))
ts:Create(game.Workspace.CurrentCamera, ti, {CFrame = game.Workspace.Cam7.CFrame}):Play()
wait(math.random(0.1, 0.5))
ts:Create(game.Workspace.CurrentCamera, ti, {CFrame = game.Workspace.Cam8.CFrame}):Play()
wait(math.random(0.1, 0.5))
ts:Create(game.Workspace.CurrentCamera, ti, {CFrame = game.Workspace.Cam9.CFrame}):Play()
wait(math.random(0.1, 0.5))
ts:Create(game.Workspace.CurrentCamera, ti, {CFrame = game.Workspace.Cam10.CFrame}):Play()
wait(math.random(0.1, 0.5))
ts:Create(game.Workspace.CurrentCamera, ti, {CFrame = game.Workspace.Cam11.CFrame}):Play()

^ current hacky code to add a simulated camera shake effect, while also tweening the camera from one part to another.

I am now curious to know if there is a more efficient way to incorporate a camera shake into a camera tween, avoiding the need for adding multiple camera “parts” with varying positions to simulate the shake effect. Any help would be greatly appreciated.

Yes you can use a RenderStepped looped and then use trigonmetric functions to get angles too apply to the cameras cframe

Script (This would be inside of a render stepped loop)

local shakeX = math.cos(os.clock() * 30) * 0.01
local shakeY = math.sin(os.clock() * 30) * 0.01

local shakeAngles = CFrame.Angles(shakeX,shakeY)
camera.CFrame = camera.CFrame:Lerp(camera.CFrame * wobbleAngles, deltaTime * 5
1 Like

Thanks for your help, but the same issue still occurs. I believe its because the CFrame can only be set once at a time, meaning that either the camera shake, or the camera movement can take priority, not both simultaneously.

This applies for both tweening the camera and lerping the camera.