I know there are plenty of topics on this, however I’m either misunderstanding something, or they don’t apply to my system.
I’m creating a Sickle system, where the arm smoothly follows and swings based off of mouse movements, and it’s been going well however I’m now stuck on rotating the arm properly independent of player rotation, Here is an example of it currently. It works properly when facing -Z, however as soon as you turn, it doesn’t work anymore.
This is my code currently, all that needs to be focused on is SwipeDirection to the Shoulder/Elbow Angle CFrame, as the rest is just inverse kinematics and as far as I believe, it doesn’t have an effect on the issue at hand (Correct me if I’m wrong please and thank you)
self.Connections.Hand = RunService.Heartbeat:Connect(function()
local Target = CFrame.lookAt(
self.RightArm.RightShoulderAttachment.WorldCFrame.Position, self.Mouse.Hit.Position)
Target = Target + Target.LookVector*4
if not self.LastTarget then self.LastTarget = Target end
--> Inverse Kinematics
local OriginCF = self.Torso.CFrame*self.C0s["Right Shoulder"]
local C1Off = self.C1s["Right Shoulder"]
local PlaneCF,ShoulderAngle,ElbowAngle, l3 = SolveIK(OriginCF, Target.Position, self.UpperArmLength, self.LowerArmLength, C1Off)
local SwipeDirection = (self.LastTarget.Position-Target.Position).Unit
if SwipeDirection.X ~= SwipeDirection.X then
SwipeDirection = Vector3.zero --> Avoid NaN
end
if self.Cumlative > 0.02 then
self.Cumlative = math.clamp(self.Cumlative+.01, -math.huge, 0)
self.Cumlative += SwipeDirection.X+self.Cumlative
elseif self.Cumlative < 0.02 then
self.Cumlative = math.clamp(self.Cumlative-.01, 0, math.huge)
self.Cumlative += SwipeDirection.X-self.Cumlative
else
self.Cumlative = 0
self.Cumlative += SwipeDirection.X
end
local ShoulderAngleCFrame, ElbowAngleCFrame = CFrame.Angles(ShoulderAngle, -math.rad(self.Cumlative*90), 0), CFrame.Angles(ElbowAngle, 0, 0)
local ShoulderCF = PlaneCF * ShoulderAngleCFrame*CFrame.new(0,-self.UpperArmLength * 0.5,0)
local ElbowCF: CFrame = ShoulderCF*CFrame.new(0,-self.UpperArmLength * 0.5,0)* ElbowAngleCFrame * CFrame.new(0, -self.LowerArmLength*0.5, 0)*CFrame.new(0,(self.Character['Right Arm'].Size.Y-self.LowerArmLength)*0.5,0)
self.Motor6Ds["Right Shoulder"].C0 = WorldCFrameToC0ObjectSpace(self.Motor6Ds["Right Shoulder"], ElbowCF)
self.LastTarget = Target
end)
I’ve tried converting it into world space, object space (Though I believe this does nothing?), object into world, world into object, but none of them have worked.
I believe that the issue arises in the SwipeDirection, but I have no idea how to fix that If anybody has any ideas or fixes I’d be so so so so grateful if you could share them
Also, if anybody has any idea on how I could smooth out / dampen the arm swing that would be greatly appreciated because I’ve also been trying to smooth that out kthxbai