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.

1 Like

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