OTS Gun System recoil

Hey! I’m trying to make a recoil system for my gun system (both FPS and OTS)

First person works flawlessly; but the OTS one feels a bit off.
https://i.gyazo.com/2d4d90a3c375a343db2434acd1d1e334.mp4

I’ve tried a ton of things; my current code is

lookat = CFrame.new(newCameraCFrame.p,(newCameraCFrame * CFrame.Angles(extra.X,extra.Y,0) * CFrame.new(0,0,-1)).p)
newCameraCFrame = lookat	

Extra is the recoil, NewCameraCFrame is the CFrame the OTS module forms every frame and I edit it to include recoil.

The issue is that it seems to be doing the recoil relative to the camera and not the character, which causes it to look like this.

I tried making it relative to the HumanoidRootPart but it made it so that the camera’s view became skewed which was even worse than this.

Does anyone have any idea what I could do to fix this?

Thanks!

If I’d go for a recoil system, I’d use the following method:

local runService = (game:GetService("RunService"));
local players = (game:GetService("Players"));

local camera = (workspace.CurrentCamera);
local recoil = (0);

function Recoil(m: multiply)
	recoil += m
end;

local RECOIL_SPEED = (3);
function UpdateRecoil(dt)
	camera.CFrame = camera.CFrame:Lerp(camera.CFrame * CFrame.Angles(recoil, 0, 0), dt * RECOIL_SPEED)
	recoil = math.max(recoil - dt * RECOIL_SPEED, 0)
end;

runService.Heartbeat:Connect(UpdateRecoil)

while wait(0.1) do
	Recoil(0.3)
end;

Note: Just updated code and the recoil is only upwards.

2 Likes