I’m trying to learn how to animate using IK via IKControl on ROBLOX, and I’m following the guide ROBLOX provides. Inverse Kinematics | Documentation - Roblox Creator Hub
I’m at the point of creating the constraint for the elbow, and after following all steps, the HingeConstraint is failing to restrict the elbow. First picture is with a target that requires very little limb motion. Second picture shows the HingeConstraint failing when the target is more challenging. The warning arrows appear, and clearly the limb shouldn’t be able to bend like that. The video in the guide shows that the PrimaryAxis for both attachments should always be identical, yet they are evidently deviating from each other in runtime. I tried activating LimitsEnabled but that didn’t alter behavior. I attempted the full guide manually (without using code) but arrived at the same problem. I was also unable to find relevant information on the DevForum. Not sure if I’m missing a step, or perhaps the guide is no longer accurate.
--This is a server script running inside a non-player character
local npc = script.Parent --The R15 skinned avatar from the native rig builder
--The following code follows the steps outlined in the official IK guide
local IKTarget = Instance.new("Attachment")
IKTarget.Name = "IKTarget"
IKTarget.Position += Vector3.new(math.random(-1,1),math.random(-1,1),math.random(-1,1) --A random target position for the sake of testing
IKTarget.Parent = npc.HumanoidRootPart
local IKControl = Instance.new("IKControl")
IKControl.Target = IKTarget
IKControl.EndEffector = npc.LeftHand
IKControl.ChainRoot = npc.LeftUpperArm
IKControl.Type = Enum.IKControlType.Transform --Set in accordance with guide
IKControl.Parent = npc.Humanoid
local LeftElbowConstraintAttachment0 = Instance.new("Attachment",npc.LeftUpperArm.LeftElbowRigAttachment)
LeftElbowConstraintAttachment0.Name = "LeftElbowConstraintAttachment0"
local LeftElbowConstraintAttachment1 = Instance.new("Attachment",npc.LeftLowerArm.LeftElbowRigAttachment)
LeftElbowConstraintAttachment1.Name = "LeftElbowConstraintAttachment1"
LeftElbowConstraintAttachment1.CFrame= LeftElbowConstraintAttachment0.CFrame --Both attachments should have the same orientation value
local ElbowConstraint = Instance.new("HingeConstraint")
ElbowConstraint.Name = "LeftElbowConstraint"
ElbowConstraint.Attachment0 = LeftElbowConstraintAttachment0
ElbowConstraint.Attachment1 = LeftElbowConstraintAttachment1
ElbowConstraint.Parent = npc.LeftLowerArm