0 votes
asked in Grounder by

Premise: i wasn't sure if this feature would be included in final IK or puppetmaster, since i'd expect to find it in the grounder script but it's commonly used with active ragdolls.

As of right now, i have a humanoid character performing a standing animation with final IK, grounder and puppetmaster active.

If i move the root gameobject around the X/Z axis then the feet will match the pose, however i'd want them try to stay in place (causing them to be dragged around instead of matching the pose) while affected by the grounder script. As if the feet were glued/pinned to the ground.

That way once i add a "walk in place" animation the feet will be pinned when close to the ground and they'll match the animation when lifted.

This way should the player look down (in first person mode) and only move a little they'll see the feet are stuck in place instead of sliding around.

I looked in the fbbik, grounded and puppetmaster scripts but i couldn't find that feature, i'd love to know if that's possible to do out of the box, otherwise i'll have to make a custom script for it (which i suspect may lead to issues in the long run knowing my luck).

I've made a tiny silly gif to illustrate what i mean in case my wording wasn't clear:

Thank you in advance. smiley

1 Answer

0 votes
answered by (17k points)

There's nothing like that in Final IK nor PuppetMaster, sorry. The grounder just applies vertical offset to the feet to match the terrain, it doesn't even know if the foot is touching the ground or not. But if you're going to take that road, here's how I would do it:

1. You can add curves to animation clips in the animation import settings. Add "L Foot Planted" and "R Foot Planted" curves to each locomotion clip you plan to use. So the curve would be at value 0 while the foot is lifted and blend to 1 while it is planted. Add float parameters with the same names to the Animator Controller.

2. Add some kind of IK for the legs - LimbIK, LegIK or FBBIK.

3. Then you can use animator.GetFloat("L Foot Planted") to know if the left foot is supposed to be planted or not and you can actually use that as left leg IK weight. If that value starts going up, that's when you know the foot stepped down. Set the position and rotation of the foot bone as the leg IK target position/rotation at that point. If the foot goes up again, it will blend IK weight to 0 and there you go.

Haven't really tried it myself, but sounds like a plan :)


commented by
I'm a bit worried that the feet will end up undershooting/overshooting the floor, but i guess that's what the grounder script does, i'll give it a try, thank you for the heads up. :)
commented by

Apparently dragging the character with the inspector causes the character to not move if both IK pins are active (even if not fully pinned), but when moving it through code then it works as expected. So i guess the issue is solved.

It looks a fair bit off but i'm sure i'll be able to improve it.

Still, i'm curious as to why changing the solver's position or positionOffset fields didn't affect the feet positions at all.


I guess i was right to be worried. :P

I've followed your suggestion and the core idea works: the animator has 2 animated floats that determine "how pinned" each foot is. 0 means unpinned, 1 means fully pinned.
Whenever a float reaches a value of 1 i read that foot's position and that becomes the IK target.


If instead of using a curve i only set those values to 0 or 1 then the leg that is "catching up" will teleport in order to match the animation, which looks unpleasant.
If both floats are above 0, then the character is unable to move as it can't drag any limb, so i can't "smooth a limb" while the other is pinned.
If i apply smoothing before the other limb is pinned, then it'll cause both legs to be raised at the same time.

So instead of setting the IK weight, i've tried to lerp the IK position while keeping a weight of 1.

If i set the target to the foot's position every frame, then the legs won't move (as i'm reading the effective foot position instead of the animation's foot position).
If i set the FBBIK target as the foot's transform itself, then it will always match the animation regardless of IK weight.
Additionally, using the solver's .position and .positionOffset fields won't allow me to change how the solver behaves (i'm doing this in the update loop).
For example if i set the offset every frame to (100000,0,0) i see absolutely no difference, likewise if i set the position to the same value nothing changes.

So the questions are:
How can i read where the foot is supposed to be in order to match the animation?
Why can't i change the position or the positionOffset if the IK target of the limb is the transform of the foot?
commented by
Were you ever able to solve this? I'm trying to do this also to avoid foot sliding and running into the same issues.


I sort of solved it but it's not super robust right now.

private float frontLeftIK;
private bool resetFL = true;
private Transform frontLeftTransform;

void Awake () {
        LeftFrontLegIK.solver.target = frontLeftTransform;

private void FixedUpdate() {
        // Get the values from the curves in the animations
        frontLeftIK = anim.GetFloat("FrontLeftDown");

        // Front left IK planting
        if (frontLeftIK == 1f) {
            if (resetFL) {
                LeftFrontLegIK.solver.IKPosition = LeftFrontLegIK.solver.bone3.transform.position;
                LeftFrontLegIK.solver.IKRotation = LeftFrontLegIK.solver.bone3.transform.rotation;
                LeftFrontLegIK.solver.IKPositionWeight = 1;
                LeftFrontLegIK.solver.IKRotationWeight = 1;

                resetFL = false;

        } else {
             LeftFrontLegIK.solver.IKPositionWeight = 0;
            LeftFrontLegIK.solver.IKRotationWeight = 0;
            resetFL = true;
commented by (17k points)


Yeah, this patch adds public void SetFootPosition(Vector3 position) to grounding legs, so you can call grounder.solver.legs[0 for left, 1 for right].SetFootPosition(position) to pin a foot to that position and the grounder will work on top of that.



Welcome to RootMotion Q&A, where you can ask questions and receive answers from the developer of Final IK and PuppetMaster and other members of the community.

Post as a guest, create an account or login via Facebook.

Please use the correct category when you post your questions.