Camera recoil with spring position does not allow for recovery

In the video attached, the camera does not achieve or perform proper recoil recovery if I apply recoil via the spring position (I am using this physics based spring system)

I’m trying to essentially use position to remedy the issue of me applying consistent recoil using this spring system, as is opposed to a Phantom Forces styled recoil system where recoil dulls after a few shots, which other dev forum posts similar to mine have worked with, hence why I am making this post.

Here is a general overview of the recoil handling:

local UserInputService = game:GetService("UserInputService");
local RunService = game:GetService("RunService");

local Spring; --- It should be the spring system provided
local RecoilSpring = Spring.FromFrequency(1, 5, 2);


local Player = game.Players.LocalPlayer;
local Camera = workspace.CurrentCamera;

local Firing = false;
local FireDb = false;

local FireRate = 600;

UserInputService.InputBegan:Connect(function(a0: InputObject)  
	if a0 == Enum.Keycode.MouseLeftButton then
		Firing = true;
	end
end)

local function ApplyRecoil()
	if Firing and not FireDb then
		FireDb = true;
		RecoilSpring:AddVelocity(10);

		task.wait(60/FireRate);

		FireDb = false;
	end
end

RunService.PreSimulation:Connect(function(DeltaTime : number) 
	ApplyRecoil();

	Camera.CFrame *= CFrame.Angles(RecoilSpring.Offset * DeltaTime, 0, 0);
end)

Thanks to anyone in advance!

1 Like