Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How can I properly implement "Half-IK" using Motor6D?

Asked by 3 years ago

I recently ripped this CCDIKController https://devforum.roblox.com/t/ccdikcontroller-alternate-inverse-kinematics-method-for-motor6d-rigs/968275 from dthecoolest, hoping to be able to implement a mixture between animations and IK using Motor6Ds.

And it works! Kind of. The IK function correctly tracks the target, even when animations are running on top of it.

Since IK gets solved every frame, the problem is this: the next frame has to adjust for the animation's new context, creating this extremely wobbly effect.

My attempted solution was to copy the time position of the animation, stop the animation (with no fade), then solve for ik, and finally resume the animation (with no fade) at the copied time position.

The reason this could be a solution relies on whether the motor6ds revert back to the position they would be in...had the animation not run in the first place. It doesn't look like this is happening, though.

My next attempt will be to apply a negative weight to the animation to account for this issue, but something tells me that won't work.

Any insight would be greatly appreciated. Thanks for reading!

The wobble: https://gyazo.com/af08cfc41516fcd1dac969c5b5b646b0

The code:

local lastframe = animationTrack.TimePosition;

RunService.Heartbeat:Connect(function(step)
    lastframe = animationTrack.TimePosition
    animationTrack:Stop(0)

    local goal = leftTarget.Position
    leftLegController:CCDIKIterateOnce(goal,nil,step) --IK Solution

    animationTrack:Play(0,1,1)
    animationTrack.TimePosition = lastframe
end)

I just noticed I missed a semicolon, haha! Good habits die hard, I guess! Actually, that's a good bonus question; if I were to use the semicolon like I would other languages, would it break anything randomly?

Answer this question