So recently, I posted another question in this category on rotating a CFrame without doing anything to the position, which I have now figured out was a mistake, as I was trying to make a fix for a solution (which probably isn’t the best), rather than find a better way of dealing with the root issue. (I did a XY problem)
So I’m making this one to sort out my real issue: I am trying to make a camera “shake” when the player fires a gun (the shake is not really a shake, more so a jerk).
The method I have been trying to use was TweenService, which pauses the camera’s position while the tween plays (very bad, because I’m using a first-person viewmodel that uses a Renderstepped function to position itself). In addition, trying to move the camera is very difficult, as the tween still tries to play, so this is not viable.
In addition, I tried using CFrame:Lerp(), which gives me the same problem that it gets really infuriating to move the camera, as the lerp keeps trying to position the camera to where you originally fired.
So, I ask you all, how do you make camera jerks and shakes? I would use Humanoid.CameraOffset, but I want the camera to rotate in any random direction, rather than move the camera to slightly different positions in a small amount of time.
This is the code I currently have. I think I may have to rewrite it and use a different solution.
local TweenService = game:GetService("TweenService")
local Info = TweenInfo.new(0.075, Enum.EasingStyle.Quad, Enum.EasingDirection.Out, 0, true, 0)
game.ReplicatedStorage.RemoteEvents.CameraShake.OnClientEvent:Connect(function(X, Y, Z)
local Goal = {}
Goal.CFrame = workspace.CurrentCamera.CFrame * CFrame.Angles(X, Y, Z)
local Tween = TweenService:Create(workspace.CurrentCamera, Info, Goal)
Tween:Play()
end)
I would gladly like help with this, please.
Thanks
(Also, if you saw my previous topic, I apologize for wasting your time and not telling you what I actually wanted to do)