I’ve got a script here, it works great, but whenever it switches magnitude in the script it makes the weapon kinda snap, any way i could give it a smooth transition?
local SetViewPosition = RunService.RenderStepped:Connect(function (dt)
local CurrentCFrame = V_Viewmodel:GetPivot()
if HumRoot.AssemblyLinearVelocity.Magnitude < 1 then
t = 0
local DefaultGunShake = math.sin(tick() * 2) * 0.05
local TargetCFrame = Camera.CFrame * CFrame.new(0 + DefaultGunShake,-4.5 + DefaultGunShake, 0.55)
print(TargetCFrame)
V_Viewmodel:PivotTo(TargetCFrame)
else
t += dt
local GunShake = math.sin(t * 5) * 0.1
V_Viewmodel:PivotTo(Camera.CFrame * CFrame.new(0 + GunShake,-4.5 + GunShake, 0.55))
end
end)
local alpha = 0.1 -- change this on how fast you want the lerp to be ]0, 1]
local TargetCFrame = Camera.CFrame * CFrame.new(0 + DefaultGunShake,-4.5 + DefaultGunShake, 0.55)
V_Viewmodel:PivotTo(V_Viewmodel.PrimaryPart.CFrame:Lerp(TargetCFrame, alpha * dt * 60))
so i anchored the torso because that was affecting it and then i raised it up to 0.99 because for some reason it was still bugging out, this is the result i got. Shotgun (2).wmv (2.0 MB)
note: sorry if this is a lil confusing but its easier than creating animated sways for each state the gun is in