You should actually study CFrames before making a post like this. It’s really not necessary to make a post just to have it explained. You should refer to the API, or review the many free tutorials on youtube about CFrames to learn. They’re not hard.
I tried studying them since morning I watched youtube and everything none of them have helped muched, I even went back to learning math. The API is bs can barely understand what they mean and what some constructors do.
Most of the time meddling with CFrames are easy. It’s usually just order of operations and basic arithmetic. For example, if I wanted to rotate a cframe around a point, I would use this operation:
rotatedCFrame = point * rotation * oldCFrame
There’s rarely a time where you need to use CFrame:GetComponents() to get all the internal values of the CFrame.
It is following the cursor but I’m trying to get the correct face to point at the mouse which is the palm currently you can see that it is the front of the arm is facing the mouse position.
Code:
local function worldCFrameToC0ObjectSpace(motor6DJoint,worldCFrame)
local part1CF = motor6DJoint.Part1.CFrame
local c1Store = motor6DJoint.C1
local c0Store = motor6DJoint.C0
local relativeToPart1 =c0Store*c1Store:Inverse()*part1CF:Inverse()*worldCFrame*c1Store
relativeToPart1 -= relativeToPart1.Position
local goalC0CFrame = relativeToPart1+c0Store.Position--New orientation but keep old C0 joint position
return goalC0CFrame
end
RunService.Stepped:Connect(function()
local goalCF = CFrame.lookAt(RightArm.Position, Mouse.Hit.Position, -Torso.CFrame.UpVector)
Torso["Right Shoulder"].C0 = worldCFrameToC0ObjectSpace(Torso["Right Shoulder"],goalCF)
end)
Here is the code guys, I’ll explain what is happening.
The front of the arm looks at the position of the players mouse after that we adjust it by 80 degrees which results in the palm facing the mouse, sounds simple but this took 2 days.
Code:
local function Point_C0_To_Mouse(Motor6D, WorldCFrame)
local Part1_CFrame = Motor6D.Part1.CFrame
local Stored_C1 = Motor6D.C1
local Stored_C0 = Motor6D.C0
local RelativeTo_Part1 = Stored_C0 * Stored_C1:Inverse() * Part1_CFrame:Inverse() * WorldCFrame * Stored_C1
RelativeTo_Part1 -= RelativeTo_Part1.Position
local Goal_C0 = RelativeTo_Part1 + Stored_C0.Position
return Goal_C0
end
RunService.Stepped:Connect(function()
local Mouse_Pos = Mouse.Hit.Position
RightShoulder.C0 = Point_C0_To_Mouse(RightShoulder, CFrame.lookAt(RightArm.Position, Mouse_Pos)) * CFrame.Angles(0,0, math.deg(-90))
LeftShoulder.C0 = Point_C0_To_Mouse(LeftShoulder, CFrame.lookAt(LeftArm.Position, Mouse_Pos)) * CFrame.Angles(0,0, math.deg(90))
end)