As the title says how do I do Inverse kinematics with 3 Motor6Ds.
I want to achieve this by setting the Motor6d’s CurrentAngle property.
XRotation rotates sideways.
Shoulder rotates up and down.
Elbow rotates up and down.
image of what I want to achieve (achieved by manually setting the values via properties).
2 Likes
This tutorial explains how inverse kinematics work, and it’s definitely worth a read: 2 Joint 2 Limb Inverse Kinematics
I applied just the angle without using CFrame.Angles from the post you referred and I am getting weird results.
local RunService = game:GetService("RunService")
local Character = script.Parent
local Target = Character.UpperTorso.RightHand
local RightSh = Character.RightUpperArm.RightShoulder
local RightRot = Character.RightUpperArm.RightShoulderJoint.RightShoulderRot
local RightEl = Character.RightLowerArm.RightElbow
local b = 2 -- UpperArmSize
local a = 1.5 -- LowerArmSize
RunService.Heartbeat:Connect(function()
local Mag = (RightSh.C0.Position - Target.WorldPosition).Magnitude
RightSh.CurrentAngle = math.acos((-a^2 + b^2 - Mag^2) / (2 * b * Mag)) + math.pi/2
RightEl.CurrentAngle = math.acos((a^2 + b^2 - Mag^2) / (2 * a * b)) - math.acos((-a^2 + b^2 - Mag^2) / (2 * b * Mag))
end)
2 Likes
Update
I solved this by myself all i had todo was account for the Motor6D offset and Character orientation offset
1 Like
What exactly does this mean? I have the same problem and want to do 3 joints, and I want to know how to do it.