making recoil for a gun, but when I try tweening the camera angle using CFrame = CFrame * Cframe.Angles() it doesn’t work to how I want it, it would stay at the cframe I activate it at, and I don’t want that, any help is appreciated!
You can lerp it by the amount you want then if you want it to come back do
cam.CFrame = cam.CFrame:Lerp(CFrame.new(), duration)
Like this?
workspace.Camera.CFrame = workspace.Camera.CFrame:Lerp(workspace.Camera.CFrame * CFrame.Angles(0.6,0,0), 1)
would would it last for a second?
Yes, but I would recommend doing around 0.1 because 1 is really slow for recoil.
Are you sure the second arguement is time, because it seems like its percentage.
I think the problem is the amount you are multiplying the camera CFrame by. Looking at the CFrameAngles part I would suggest you use math.rad(degrees) to get a more accurate result.
Yep I did that, workspace.Camera.CFrame = workspace.Camera.CFrame:Lerp(workspace.Camera.CFrame * CFrame.Angles(-5,0,0), 0.1)
But it seems to instant, unlike a tween
You can slowly increase the second argument until you are satisfied.
Tried doesn’t lower the speed in any way instead it increased the percentage of the lerp
Try that:
local function recoil()
local speed = .25
local rotation = CFrame.Angles(math.rad(30), 0, 0)
for i = 0, 1, speed do
local targetCFrame = camera.CFrame * rotation
camera.CFrame = camera.CFrame:Lerp(targetCFrame, i)
wait()
end
end
recoil()
Lowers the firing rate. which is a problem.
My fault, just wrap it in a spawn:
local function recoil()
local speed = .25
local rotation = CFrame.Angles(math.rad(30), 0, 0)
task.spawn(function()
for i = 0, 1, speed do
local targetCFrame = camera.CFrame * rotation
camera.CFrame = camera.CFrame:Lerp(targetCFrame, i)
task.wait()
end
end
end
recoil()
Thank you!! was stuck on it for hours