I current have made my own FABRIK module, but in it’s current form, it’s very simple.
In my attempt to make it more customizable, I want to add Joint Constraints to it.
So for example if the constraints are (1, 0, 0), then it only rotates on the X axis relative to the previous bone or the Origin, (Which is a CFrame)
I’ve tried getting the previous bone’s CFrame and then multiplying the gotten orientation before making it global again, but all that did was make the Limb freakout and it didn’t give me the result I wanted.
STEPPING FUNCTIONS:
function ik:forwardStep()
for i1 = #self.Limbs, 1, -1 do
local i2 : number = i1 - 1 --ORIGIN LIMB
local i3 : number = i1 + 1 --TARGET LIMB
local limbOrigin : Vector3 = self.Origin.Position
local limbTarget : Vector3 = self.Target
if i3 <= #self.Limbs then
limbTarget = utilities.getLimbStart(self.Limbs[i3], self.Lengths[i3]).Position
end
if i2 > 0 then
limbOrigin = utilities.getLimbEnd(self.Limbs[i2], self.Lengths[i2]).Position
end
local desiredCFrame : CFrame = utilities.cframeMoveTo(self.Lengths[i1],limbOrigin,limbTarget)
self.Limbs[i1] = desiredCFrame
end
end
function ik:backwardStep()
for i1 = 1, #self.Limbs do
local i2 : number = i1 - 1--ORIGIN LIMB
local i3 : number = i2 + 1 --TARGET LIMB
local limbOrigin : Vector3 = self.Origin.Position
local limbTarget : Vector3 = self.Target
if i3 <= #self.Limbs then
limbTarget = utilities.getLimbEnd(self.Limbs[i1], self.Lengths[i1]).Position
end
if i2 > 0 then
limbOrigin = utilities.getLimbEnd(self.Limbs[i2], self.Lengths[i2]).Position
end
self.Limbs[i1] = utilities.cframePointTo(self.Lengths[i1],limbOrigin,limbTarget)
end
end