So I am useing https://devforum.roblox.com/t/ez-fabrik-ik-v1-3-inverse-kinematics-intended-for-any-motor6d-rig/ for my tripod.
Now I have edited the script and my model for it to work. I have rigged up the Motor6D for the joints. I have tested but moving any of the “BigRTarget/BigLTarget/BigBTarget” wont move. The Motor6d will work though, I can edit them within properties and the move. I Should Note I am using Meshs.
--Get service
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local RunService = game:GetService("RunService")
--Modules required
local IKControllerPointer = ReplicatedStorage.Source.LimbChain
local LimbChain = require(IKControllerPointer)
--Left leg chain motors
local tripod = workspace.Tripod
--Dont mess with root motor or else entire body will speeen
local lowerTorsoMotor = tripod.HumanoidRootPart
--Get the motors of the left leg chain
local lUpperLegMotor = tripod.Torso.LUpperLeg
local lLowerLegMotor = tripod.LLeg.LUpperLeg.LLowerLeg
local lfoot = tripod.LLeg.LLowerLeg.LFeet
--Get the motors of the right leg chain
local rUpperLegMotor = tripod.Torso.RUpperLeg
local rLowerLegMotor = tripod.RLeg.RUpperLeg.RLowerLeg
local rfoot = tripod.RLeg.RLowerLeg.RFeet
--Get the motors of the back leg chain
local bUpperLegMotor = tripod.Torso.BUpperLeg
local bLowerLegMotor = tripod.BLeg.BUpperLeg.BLowerLeg
local bfoot = tripod.BLeg.BLowerLeg.BFeet
--Create the left leg chain
local leftLegMotorTable = {lUpperLegMotor,lLowerLegMotor,lfoot}
local leftLegChain = LimbChain.new(leftLegMotorTable)
--create the right leg chain
local rightLegMotorTable = {rUpperLegMotor,rLowerLegMotor,rfoot}
local rightLegChain = LimbChain.new(rightLegMotorTable)
--Create the back leg chain
local backLegMotorTable = {bUpperLegMotor,bLowerLegMotor,bfoot}
local backLegChain = LimbChain.new(backLegMotorTable)
RunService.Heartbeat:Connect(function()
local leftTarget = workspace.BigLTarget.Position
local rightTarget = workspace.BigRTarget.Position
local backTarget = workspace.BigBTarget.Postition
leftLegChain:IterateOnce(leftTarget,0.1)
leftLegChain:UpdateMotors()
backLegChain:IterateOnce(backTarget,0.1)
backLegChain:UpdateMotors()
rightLegChain:IterateOnce(rightTarget,0.1)
rightLegChain:UpdateMotors()
end)
Sorry but can you send a photo of the rig edit structure? Plus are there any errors in the output? Edit: I also see welds constraints are they perhaps interfering with the rig?
Oh, that error means that you haven’t indexed the LUpperLeg properly. Looking at the hierarchy it’s within the Torso and the LLeg. Instead of indexing the Motor6D’s manually which I did initially, I recommend using a loop to get them and storing them in a dictionary assuming the Motor6D’s have been named uniquely
local tripod = workspace.Tripod
local modelMotor6Ds = {}
local modelDescendants = tripod:GetDescendants()
for _,descendant in pairs (modelDescendants) do
if descendant:IsA("Motor6D") then
modelMotor6Ds[descendant.Name] = descendant
end
end
--now you can index the Motor 6d's by name through the dictionary obtained
local LUpperLegMotor = modelMotor6Ds["LUpperLeg"]
Also yeah make sure you rigged it properly. I’m currently using RigEdit which creates a joint structure like this:
Well, it’ll need to be properly rigged where the Motor6D’s already had their C0 and C1 Positions set which RigEdit lite does for you. However, another way to know if it’s properly rigged is to insert an animation controller/humanoid in the model then attempt to manually animate it. If the joints rotate as it should then it’ll be good.
This is because in theory, my IK creates a vector from joint to joint:
Indexing is when you access data in the game which is what you were already doing previously using the . to access the Tripod model in the workspace
local tripod = workspace.Tripod
Now here is the automated version using a dictionary to find the Motor6D’s, try it out.
--Get service
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local RunService = game:GetService("RunService")
--Modules required
local IKControllerPointer = ReplicatedStorage.Source.LimbChain
local LimbChain = require(IKControllerPointer)
--Left leg chain motors
local tripod = workspace.Tripod
local modelMotor6Ds = {}
local modelDescendants = tripod:GetDescendants()
for _,descendant in pairs (modelDescendants) do
if descendant:IsA("Motor6D") then
modelMotor6Ds[descendant.Name] = descendant
end
end
--now you can index the Motor 6d's by name through the dictionary obtained
--Get the motors of the left leg chain
local lUpperLegMotor = modelMotor6Ds["LUpperLeg"]
local lLowerLegMotor = modelMotor6Ds["LLowerLeg"]
local lfoot = modelMotor6Ds["LFeet"]
--Get the motors of the right leg chain
local rUpperLegMotor = modelMotor6Ds["RUpperLeg"]
local rLowerLegMotor = modelMotor6Ds["RLowerLeg"]
local rfoot = modelMotor6Ds["RFeet"]
--Get the motors of the back leg chain
local bUpperLegMotor = modelMotor6Ds["BUpperLeg"]
local bLowerLegMotor = modelMotor6Ds["BLowerLeg"]
local bfoot = modelMotor6Ds["BFeet"]
--Create the left leg chain
local leftLegMotorTable = {lUpperLegMotor,lLowerLegMotor,lfoot}
local leftLegChain = LimbChain.new(leftLegMotorTable)
--create the right leg chain
local rightLegMotorTable = {rUpperLegMotor,rLowerLegMotor,rfoot}
local rightLegChain = LimbChain.new(rightLegMotorTable)
--Create the back leg chain
local backLegMotorTable = {bUpperLegMotor,bLowerLegMotor,bfoot}
local backLegChain = LimbChain.new(backLegMotorTable)
RunService.Heartbeat:Connect(function()
local leftTarget = workspace.BigLTarget.Position
local rightTarget = workspace.BigRTarget.Position
local backTarget = workspace.BigBTarget.Position
leftLegChain:IterateOnce(leftTarget,0.1)
leftLegChain:UpdateMotors()
backLegChain:IterateOnce(backTarget,0.1)
backLegChain:UpdateMotors()
rightLegChain:IterateOnce(rightTarget,0.1)
rightLegChain:UpdateMotors()
end)
There is an error in line two. local IKControllerPointer = ReplicatedStorage.Source.LimbChain Replicated Storage has been Underlined. line 45 RunService Is also Underline
Fixed the Problem for line 2 local IKControllerPointer = game.ReplicatedStorage.Source.LimbChain
fixed the run service. Now It counts local RunService = game:GetService("RunService")
But Now local backTarget = workspace.BigBTarget.Postition wont work.
No idea, but I hotfixed the position of the vector joints, seems like my initial method didn’t work for really long legs. Now onto the current major issue, the model, yeah because the mesh parts are rotated it’ll act weird and this will mess with the CFrame math currently implemented. For reference every part in the basic R6 rig is orientated (0,0,0)
However the solution for now would be create a basic part 0 and part 1 block that is orientated (0,0,0) then rig this part0 and part 1 to work with the IK method. I have had this problem before and currently I’m not too sure how to fix it, so I’m currently working on another IK method CCDIK.