So I’ve been making a rope swinging game for a few months now, and decided to add viewmodels, but I’ve got stuck on this problem where I need the arms to rotate realistically as if you were actually swinging.
The issue is, is every time I try and apply a rotation to them it just kind of goes wonky.
I’ve tried my own ideas, other ideas, other people’s code and just can’t get it to work properly.
Expected Behavior:
Current Code:
Point two
is the point where the rope is created, it is an attachment instance
if pointTwo then
local direction = pointTwo.WorldPosition + (Vector3.new(CFrame.new(Viewmodel.RightForearm.Position, pointTwo.WorldPosition)) * 5000)
local rootCFrame = Viewmodel.HumanoidRootPart.CFrame
local rotationOffset = (rootCFrame - rootCFrame.p):inverse()
Viewmodel.HumanoidRootPart.RightForearm.Transform = rotationOffset * CFrame.new(Vector3.new(0, 0, 0), direction) * CFrame.Angles(math.rad(math.pi / 2), 0, 0)
end
If you need more clarification on anything let me know.