I am using Quenty’s spring module for my weapon sway spring system. The issues I am having are, number one I cannot play animations over the weapon because I am setting the parts CFrame I believe, number two whenever I walk with my weapon and look around my player starts moving around in strange ways, number three When the player is not moving their mouse for a few seconds the weapon and arms disappear. Please help me understand why these issues are occuring thanks.
The two biggest issues I am having is the animation not playing on the part that I am applying the spring to and the biggest issue is that even when I set cancollide false the weapon is still able to push the player around when the player looks down and around.
Local Script in tool setting the parts CFrame:
local cameraOffset = CFrame.new(0.8, -0.75, -2.45)
local camera = CamXE
local RunService = game:GetService("RunService")
local Spring = require(script:WaitForChild("Spring"))
local ZEROVECTOR =Vector3.new()
local viewmodelSpring = Spring.new(ZEROVECTOR)
viewmodelSpring.Speed = 4
viewmodelSpring.Damper = 5 --1 is perfect dampening
local function clampMagnitude(vector, maxMagnitude)
return (vector.Magnitude > maxMagnitude and (vector.Unit * maxMagnitude) or vector)
end
local deltaSensitivity = 0.5 -- increases force from mouse delta
local previousGoalCFrame = CFrame.new()
RunService.RenderStepped:Connect(function()
if not LookGP then
return
end
local goalCFrame = camera.CFrame*cameraOffset
part.CFrame = goalCFrame
--Spring stuff
local differenceCF = previousGoalCFrame:ToObjectSpace(goalCFrame)
local axis, angle = differenceCF:ToAxisAngle()
local angularDisplacement = axis*angle
previousGoalCFrame = goalCFrame
local springForce = angularDisplacement*deltaSensitivity
viewmodelSpring:Impulse(springForce)
local partSpringOffset = viewmodelSpring.Position
local axis = partSpringOffset.Unit
local angle = partSpringOffset.Magnitude
part.CFrame *= CFrame.fromAxisAngle(axis,angle) * CFrame.Angles(0, math.rad(180), 0) * gunCfOffsetVal.Value * gunShotVal.Value
end)