Whenever I try to tween the camera (I’m making a recoil effect) it works but it freezes in place and then snaps back to the player after it’s completed. Is there any alternative for this that I can use where the issue doesn’t happen or can I fix this while still using the tween method?
Could we have any footage? Or code?
local module = {}
module.__index = module
--[[
f = -kx - bv
f = the overall force
k = the direction of the force
x = the strength of the force
b = the dampening effect amount (related to force)
v = the velocity of the point
(thanks to encrypt)
--]]
function force(k, x, b, v)
return k * x - b * v
end
function module.new(k, x, b, v)
local spring = setmetatable({}, module)
if k < 0 then
spring.K = -math.abs(k)
else
spring.K = -k
end
spring.X = x
spring.B = b
spring.V = v
return spring
end
function module:Oscillate(Camera)
local TS = game:GetService("TweenService")
local F = force(self.K, self.X, self.B, self.V)
--task.spawn(function()
-- task.wait(.2)
-- F = false
--end)
while task.wait() do
if F then
F = F / -1.5
TS:Create(
Camera,
TweenInfo.new(
.1
),
{
CFrame = Camera.CFrame * CFrame.Angles(math.rad(F),0,0)
}
):Play()
end
end
end
return module