I wrote a sway script for walking and turning. Somehow when the firing animation plays, the gun lags back? (I have no idea how to describe this) I am looking for an explanation and a fix, if even possible. Video and code is shown down below.
Video:
Code:
local ToObjCFrame = Camera.CFrame:ToObjectSpace(lastCamCF)
local X,Y,Z = ToObjCFrame:ToOrientation()
lastCamCF = Camera.CFrame
if IsAiming ~= true then
SwayCF = SwayCF:Lerp(CFrame.new(
math.sin(ToObjCFrame.X) * currentMotionSwayAMT,
0,
math.sin(ToObjCFrame.Z) * currentMotionSwayAMT),
.1)
else
SwayCF = SwayCF:Lerp(CFrame.new(
math.sin(ToObjCFrame.X) * currentMotionSwayAMT,
0,
0),
.1)
end
AngularSwayCF = AngularSwayCF:Lerp(CFrame.Angles(
math.sin(X) * currentAngularSwayAMT,
math.sin(Y) * currentAngularSwayAMT,
math.sin(X) * currentAngularSwayAMT),
.1)
I will give out as much info as you need. Thanks