Inverse Kinematics for Tripod

I was doing some test and found this quite funny. https://i.gyazo.com/cdbfc86db9a27af3700bcf033af96868.mp4

How Would I do the Foot placing system, on my tripod? As the MultiChain and the mech constraint Test are both written diffently.
Ok So I just added it to the script and changed thing around. Still would not work, but the IK still works and no errors in the output.

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["LFoot"]

--Get the motors of the right leg chain
local rUpperLegMotor = modelMotor6Ds["RUpperLeg"]
local rLowerLegMotor = modelMotor6Ds["RLowerLeg"]
local rfoot = modelMotor6Ds["RFoot"]

--Get the motors of the back leg chain
local bUpperLegMotor = modelMotor6Ds["BUpperLeg"]
local bLowerLegMotor = modelMotor6Ds["BLowerLeg"]
local bfoot = modelMotor6Ds["BFoot"]

--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)

--Foot placement system
local footParams = RaycastParams.new()
local ignoreParts = workspace:WaitForChild("RayFilterFolder")
footParams.FilterDescendantsInstances = {tripod,ignoreParts}

leftLegChain.FootPlacementRaycastParams = footParams
leftLegChain.LengthToFloor = 80

local down = Vector3.new(0,-80,0)

RunService.Heartbeat:Connect(function()
	
	local goalPosition = workspace.BigLTarget.Position
	local goalRightPosition = workspace.BigRTarget.Position
	local goalLeftPosition = workspace.BigRTarget.Position
	local rayResult = workspace:Raycast(goalPosition,down,footParams)
	if rayResult then
		leftLegChain:IterateOnce(rayResult.Position,0.1)
	end
	leftLegChain:UpdateMotors()

	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)

TripodTest.rbxl (1.1 MB)

Ok for the foot placement system, you gotta add the bool option to the constructor.

local leftLegChain = LimbChain.new(leftLegMotors,true)

Then you will have to add attachments to the object

--Get all the attachments in the left foot
leftLegChain.FootBottomAttachment = lowerBody.LeftLeg.LFeet.FootBottom
leftLegChain.FootBottomRightAttachment = lowerBody.LeftLeg.LFeet.FootBottomRight

The raycasting will begin at these two points and the foot will orient to the normal accordingly. For the other posts that you deleted with the procedural animator make sure you understand both OOP and module scripts because well the code I gave is mostly experimental and not complete so you can’t execute it simple with just one function.

1 Like

When you talking about attachment are you meaning about ball sockets?
Oh wait nvm as it’s already motor 6d connected. Oh and I think I understand stand why there is an attachment there as it is were the ray casting starts from

Could you explain to me why both feet(or for me three feet) have all the attachments to the left leg. I have notice a theme with the left leg. Is the left leg just a parent starting place for the script to properly work?
Edit: So I did it and it worked normally. So I though i could put the attachments to the proper foot. I edited the script. I checked if there were any errors and there were not and the left foot is twisted backwards. Anything I should do?

--Foot placement system
local footParams = RaycastParams.new()
local ignoreParts = workspace:WaitForChild("RayFilterFolder")
footParams.FilterDescendantsInstances = {tripod,ignoreParts}

leftLegChain.FootPlacementRaycastParams = footParams
leftLegChain.LengthToFloor = 80

leftLegChain.FootBottomAttachment = tripod.LLeg.LFoot.FootBottom
leftLegChain.FootBottomRightAttachment = tripod.RLeg.RFoot.FootBottomRight
leftLegChain.FootBottomBackAttachment = tripod.BLeg.BFoot.FootBottomBack

local rightLegChain = LimbChain.new(rightLegMotorTable,true)
local backLegChain = LimbChain.new(backLegMotorTable,true)

TripodTest.rbxl (1.1 MB)

Oh that’s actually a typo error caused from me copy and pasting the leg code and forgetting to change the attachments.

And honestly for the foot placement system I would suggest entirely rewriting the foot placement code, using two attachments isn’t accurate enough to get the surface normal of the floor. I would suggest using a three attachment system to get the plane surface of the floor like how easy entities by QuasiDuck does it. You can fork the edits in LimbChain :UpdateFootMotors function which controls the last motor and see how it works.

1 Like

Hello, I am Back.
So With the New CCDIK, I know that now I can have them orientated any way. Any Things I know. Like with the Motors and foot attachments? I know that I am going to have to make some modifications to the Multichain tripod Script.