Hi, I am having an issue with this viewmodel, here’s the problem:
In third person the melee will swing normally, the torso is rotated and the melee is influenced based on animation, but when I go in first person, the arms swing just fine, but the torso is completely ignored, so I have to change the animation to look less detailed (less torso rotation) in order to make it work in first person and third person.
— Here is the block of code that makes the arms move in first person
if LeftShoulder then LeftShoulder.C0 = LeftShoulder.C0:Lerp((Camera.CFrame * CFrame.new(-1, -1, 0) * cframe):ToObjectSpace(Torso.CFrame):Inverse() * CFrame.Angles(0, -math.pi / 2, 0), 0.35) end
if RightShoulder then RightShoulder.C0 = RightShoulder.C0:Lerp((Camera.CFrame * CFrame.new(1, -1, 0) * cframe):ToObjectSpace(Torso.CFrame):Inverse() * CFrame.Angles(0, math.pi / 2, 0), 0.35) end
end
FirstPerson = true
Try swapping the order transform*Torso.CFrame, order matters a lot in Cframe and sometimes it fixes the problem from my experience.
Otherwise you can try solving for the torso CFrame frome the humanod root part using the weld formula where part 0 is the humanoid root part and part 1 is the torso CFrame that is being solved.
----motor.part0*c0*transform = motor.Part1*C1
--Solve for Part1
--motor.part0*c0*transform*C1:Inverse() = motor.Part1
CFrames are weird tbh just keep trying to change it and eventually you can reach the goal.