How to get the joints between a starting joint and end joint? (Joint hierarchy)

Hello,

I’ve been at this for a while and somehow haven’t found a reliable solution yet, not from myself, or various sources online which is why I’m here.

I’m looking for a way to get a joint hierarchy from a ChainRoot and EndEffector much like how the IKControl instance does before applying inverse kinematics.

For instance,

print (GetJointHierarchy (RightShoulder, RightWrist))

would print

{RightShoulder, RightElbow, RightWrist}

So far the most I know for sure is that an iterative approach should be taken.

local function GetJointHierarchy (ChainRoot, EndEffector)
	local Hierarchy = {}
	local CurrentRoot = ChainRoot

	while CurrentRoot ~= EndEffector do
		-- Proceed to next root
		-- Add to Hierarchy
	end
	return Hierarchy
end

As you can see, I need help with practically everything.

The most difficult part will be ensuring that the function considers the possibility a single root might diverge into multiple paths, with only one reaching the EndEffector.

This has been really scratching my brain, so please; any help is appreciated.

1 Like

Add the current root’s name to the hierarchy. If the current root is the EndEffector, break the loop, Iterate through the children of the current root to find the next joint (either Motor6D or Bone ). Update CurrentRoot to the next joint’s Part1 .

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.