How to stop bones from clipping through objects during animations?

I recall seeing a video in the monthly WIP thread a long time ago that was using the new Animation System with inverse kinematics and physics ( I think?) to make an animated character model go up a set of stairs without having its walk animation cause the feet to clip through the stairs.

I am trying to figure this out now that I am working with the DynamicAnimControl and AnimComposer on 3.3 for my NPCs, but can’t find that topic and I am struggling to figure anything else out on the idea.

I was going to procrastinate this problem until a later date, as I thought this feature was mostly a visual thing that wouldn’t affect gameplay, even though the animation clipping with feet and legs can get really ugly in hilly and uneven areas.
However, now that I am working with the DynamicAnimControl’s ragdoll and dynamic modes that interact with physics, I have noticed that it is imperative that the legs are not clipping through any other phyics bodies when a walk animation is playing with the AnimComposer. From my testing so far, this can accidentally (and wrongly) pin the NPC to the ground if the DAC’s ragdoll or dynamic force mode gets activated while a limb is clipped through another physics object.

This functionality also seems necessary for making an NPC recover from a big fall / knockback that uses ragdoll mode. Once an NPC is done being knocked back they will be laying on the ground in the DAC’s ragdoll mode, then I blend to kineamtic mode while rotating the the NPC onto its stomach and playing a stand animation, so the NPC can recover - but while this recovery process occurs, the bone clipping is very noticeable.

Any help figuring out how to do this type of Inverse Kinematics with animations and physics is greatly appreciated :slightly_smiling_face:

1 Like

i dont really think IK walking example were avoiding clipping, but rather “set IK point to stairs contact point” i guess.

But for your problem i have some idea like setting “collision bone with wall”(and adjacent bones) to ragdoll mode, while keep other bones in animation mode.

Anyway i would suggest avoiding much collision detection since its all additional physics work, thats why many games have like “ragdoll limit” setting too.

here some example(old test video i had just to quick show, start from 0:17):

where i set ragdoll mode for a moment on collision for a adjacent bones of collision bone.

1 Like

I’m not sure if I was correct to use the term Inverse Kinematics. But I do know I have seen this feature in other 3d games, where the character’s walk animation adjusts as they are going up a hill, so their thighs get pushed higher to make sure the feet don’t clip through the up-hill terrain. I am not sure what that is called, but it would be a great feature in JME and I think it should be possible to do with something like DAC’s physical bone capabilities.

I am curious if you have done any stress testing on a desktop device to know what are the capabilities and how many ragdolls you can have at once?
I haven’t gotten that far yet myself, but I am hoping I can manage to minimize the performance impact by only using the ragdoll mode for a few seconds at a time when a knockback occurs.

And then depending on the results of my stress testing, I am planning to write all of my game’s spells/abilities with knockback effects so that they have low radiuses, or I will dissipate the impact for enemies that are further from the center or if they are behind many other enemies. I am going off of the assumption that I should be able to have at least 3-4 enemies in ragdoll mode for a 2-3 second span of time, so anything more than that would be a bonus. But I still havent’ gotten far enough to stress test lots of DACs at once yet myself so hopefully I’m not wrong on that :laughing:

I also don’t use physics for anything else in my game aside from static bodes, and use my own very light weight physics for movement and normal NPC push-physics. So I hope that my minimal use of Physics will help the fps as well so I can use as many DACs at once as possible.

2 Likes

Yes you are right, what i mean is that IK adjust feet bone to some point, and this point can be calculated for example via simple “Raycast” instead using full ragdoll system. But i might be wrong, i just thoguht it would be faster than using default bone collision all the time.

I am curious if you have done any stress testing on a desktop device to know what are the capabilities and how many ragdolls you can have at once?
I haven’t gotten that far yet myself, but I am hoping I can manage to minimize the performance impact by only using the ragdoll mode for a few seconds at a time when a knockback occurs.

This all depends on Bones amount and complexity of skeletons, so hard to tell.

For example i would avoid using fingers/tips/etc in ragdoll mode. Even avoid eyes when in ragdoll mode to make it work faster.

Or make it LOD based, its also possible. Far ragdolls could be just 2 bones really :slight_smile:

1 Like

Are there any new developments?

1 Like

I never made any more progress on this unfortunately.

I had a few ideas to try out using Minie’s DynamicAnimControl but didn’t feel confident enough that my ideas would work and look good enough to justify working on this instead other things at the time.

I had two general ideas I was going to start with though:

The first idea I have is to do a completely procedural walk animation with code for the legs where I’d try using the setDynamic() method in the DAC to guide the feet up and down in an elliptical shape and hopefully it would look like walking when the feet collide with the ground, but I had a hunch that I probably would not be able to do this well without spending a lot of time tweaking things with trial and error. I also have lots of different animals in my game with 4 legs and slightly different walk cycles, so trying to make a clean procedural walk animation for all of my unique animated models could be difficult and time consuming; or maybe not, I haven’t attempted anything so I’m just speculating still.

And the second Idea I had (that I expect would be easier if its even possible) was to try something where I let the legs play their normal walk animation, and then if the feet or legs clip through something (like sloping ground or stairs) then I would just reposition the joints upwards at the Y level of the collided object. It sounds easy enough, but I expect the results could also end up real sloppy and buggy and could look nothing like what I expect, depending on how the AnimComposer responds when a joint gets its transform manually adjusted in the middle of an animation.

If I get around to this anytime soon and make any substantial progress I’ll post back with more information. Although I am still interested to hear if anyone else has any other ideas / insights, or if anyone else makes any progress on this in the mean time.

2 Likes

Thank you for providing a very good development idea

1 Like