A good method for this is to move the torso (main part which is not IK) forward. When the legs, which are IK, cannot reach the red cubes, move the red cubes forward to the original offset. Repeat. This will give the illusion of walking.
As for the module itself, great job! Looks so smooth!
Sure. Or, you can anchor the mech’s torso and lerp the CFrame to move it. For collisions, you would use :GetTouchingParts() and raycast to find the direction of collision. It’s a bit advanced, but would give you more control.
Or, alternatively, you can just use a humanoid with supports/fake legs
I cant anchor the torso due to Network ownership (for smooth player control) . Also I have been using humanoid. So from that I am going to create invisible legs for support .
Then I will find a good offset position for the red parts alternating with maybe a debounce system? Only thing I cant work out is going left and right. I am also assuming ill use CCDIKIterateUntil.
Thank you for the quick and helpful responses I am quite new to DevForums so this has given me a great first experience pro man.
Hello! This module is just Awesome! But sadly the Github Page is missing
And so I’ve got 0 idea on how to use this module, it’d be great help if you could fix it, or maybe add a tutorial here!
After I was contacted by someone who wanted a version which could be compatible with animations I have decided to officially push a version which fixes the error.
Before:
After:
Notice how the idle animations are moving the IK effected limb:
The only difference is that for it to work the iteration should be done within .Stepped.
--Stepped for the CCDIK to reset the .Transform property
RunService.Stepped:Connect(function()
local goal = leftTarget.Position
leftLegController:CCDIKIterateOnce(goal,0) --0 tolerance always try to iterate towards goal
end)
The explanation on how it works is that it will:
Apply the .Transform animations onto the C0 instead
Perform the usual move limb closer towards the goal
Then apply constraints
In the proper order instead of:
Perform the usual move limb closer towards the goal
Then apply constraints
Then animations are applied moving them out of the constraint range
CCDIK iterate step function fixed
function CCDIKController:_CCDIKIterateStep(goalPosition, step)
local constraints = self.Constraints
local useLastMotor = self.UseLastMotor and 1 or 0 --Makes it so that it iterates the only one motor in the table
for i = #self.Motor6DTable - 1 + useLastMotor, 1, -1 do
local currentJoint = self.Motor6DTable[i]
currentJoint.C0 *= currentJoint.Transform -- apply animations to C0
self:RotateFromEffectorToGoal(currentJoint, goalPosition, step)
currentJoint.Transform = CFNEW()
if constraints then
local jointConstraintInfo = constraints[currentJoint]
if jointConstraintInfo then
if jointConstraintInfo.ConstraintType == "Hinge" then
self:RotateToHingeAxis(currentJoint, jointConstraintInfo)
end
if jointConstraintInfo.ConstraintType == "BallSocketConstraint" then
self:RotateToBallSocketConstraintAxis(currentJoint, jointConstraintInfo)
end
end
end
end
end
Add constraints to make the arms bend the right way by using the :GetConstraints() function. Remember to create the Constraint Instances and attachment like the example in the test place.
So I’m back again unfortunately, so the IK legs make the mech rotate into another direction when its idle. Is this something to do with my code? I may have converted some of the C# into LUA incorrectly. I use a heartbeat script to update the IK legs every second. If this isnt enough information i can give you more. Sorry if this is asking for to much.
I’m honestly not sure, but here’s some ideas to debug with
What’s the front face of the legs and the mech? Are they all facing the same direction?
If this is not the issue, then I would want to know what “idle” means. I doubt it’s your code causing the bug, but rather the default behavior of the module
I am going to supply a video to show what I mean by “idle” also the legs and mech are facing the correct position. Hopefully you can help me work out a solution lol.
I might try ditch the idea of IK and just use normal animations since im to dumb to work this out lol. Or i might try rework the code with my own ideas lol. I’m just really confused on how to get this working. I might try maybe allowing for a normal humanoid rig to be able to work in IK then use that logic for a mech?
Hi, it’s been a heck of a few days, and I missed your responses. I would recommend first fixing the leg issue where it lags behind the torso.
To fix this, you’re gonna make sure that your raycast is from the torso down. When the legs step forward, then they should be directly under where the torso was when they started stepping forward. You might have to lower the walkspeed for this.
You might find the rotating fixed. I think the physics were messing with it. I would heavily recommend to anchor all parts and not use a humanoid.