0 votes
asked in Grounder by

I recently asked you how i could pin the feet of my character in worldspace when they touch the ground and you proposed to add a curve in my animations that will determine how pinned each foot is.

While that solution does work, i was wondering if something more generic could be achieved, as i'd always want to pin the feet if they're close enough to the ground.

I could do a raycast of my own, but the grounder script already does that alongside a capsule cast for each foot.

Plus if my raycast differs from the one of the grounder it's possible that i pin a limb when it's supposed to move, which i'd rather avoid. :)

I looked at the documentation and i noticed that i could use GrounderFBBIK.solver.legs[n].heightFromGround; in order to find how far each foot is from the ground.

However, the end result isn't what i hoped for, the distance i get is almost completely unrelated to the height of the foot from the ground and the end result changes a fair bit based on the height offset.

The blue trail is the motion of grounder.solver.legs[n].IKPosition; while the red trail is the motion of grounder.solver.legs[n].IKPosition - new Vector3(0.01f,grounder.solver.legs[n].heightFromGround,0);

The ground is a flat plane, character, trails and everything else except the ground plane is set to layer "IgnoreRaycast", the grounder checks for "Default" and behaves correctly.

Height offset too low (0), character floats

Height offset correct (-0.22)

Height offset too high (-0.33), character sinks into the ground

Using the second image as reference, you can see how in the circled area the heightFromGround matches the animation, despite the foot being almost at peak height (you'd thus expect the red line to be quite far away from the blue one).

This is how the two trails are supposed to look like (i made a raycast of my own):

The red trail is obtained with: grounder.solver.legs[n].IKPosition + new Vector3(0.02f, Vector3.Distance(grounder.solver.legs[n].IKPosition, hit.point), 0);

You can see how the closter the feet are from the ground the shorter the height becomes, since i'm calculating from the center of the foot the two never match.

I also tried IKOffset and stepHeightFromGround, but those did not help either.

What am i doing wrong?

1 Answer

0 votes
answered by (16.3k points)

heightFromGround is probably not the best name for that parameter. Its actually more like "how much the foot needs to be lowered to match it's height from the ground collider to it's height from the root in the animation".

Anyway, using Grounder raycast for that might give you strange results, as it's not raycasting from the foot, but from a predicted position of the foot, as it needs to raise/lower the foot in advance.

But if you want to use foot height in animation to define if the foot is planted or not, you don't need the Grounder for that, you can just read foot.position.y - root.position.y in LateUpdate, where the character pose is as animated.


asked Mar 20 in Grounder by ivan
0 votes
Read Grounder's calculated feet height

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.