BetterCharacterController bouncing off of the ground while moving

Thank you, @xuan! Your gist was very helpful.

I’ve reproduced the issue on Linux with the latest Minie commit. Currently I am working to simplify the code into a test that’s 100% reproducible, in order to simplify debugging.

An intriguing clue: the bounce is larger when the character is traveling fast than when it’s traveling slow.

Edit—I’ve opened an issue against Minie and am continuing to study it: BetterCharacterController hops across seams · Issue #18 · stephengold/Minie · GitHub

5 Likes

Great initiative @sgold. Hope you find something.

1 Like

I’m still investigating this issue. It’s going slowly. Currently I’m 90% convinced it’s a bug in Bullet, the contact normal being calculated incorrectly for a MeshCollisionShape. If so, that might explain some issues I’ve seen with rigid bodies on flat surfaces, for instance in PoolDemo.

Okay, I think I’ve found a good solution. (I’d feel more confident if the issue hadn’t been known and unsolved in Bullet for the past 13 years!)

I hope to include the fix in a new release of Minie, to appear in the next couple days.

11 Likes

Amazing work @sgold !

1 Like

Thanks, @sgold! Great job :slightly_smiling_face:

1 Like

I have encountered a similar rigid body jitter problem before, maybe you can take a look at this old post. :wink:

The issue discussed here is an occasional deflection of a character’s motion. I wouldn’t describe it as “jitter”. Jitter is a small movement that occurs continually.

This issue occurs only when the character crosses a boundary between 2 triangles in a mesh or heightfield. It is caused by incorrect contact forces between the character and the ground. It is most visible at high speeds.

I think the character in TestBetterCharacter moves too slowly for this issue to be visible.

Paul thought the jitter problem you reported in TestBetterCharacter was caused by updating the camera too soon. If so, it’s not related to this issue.

1 Like

Yep, with that much jitter, if it were a physics problem the character would be bouncing all over the place from forces… and that fact that it happens with either control indicates not physics related.

…where as the jitter problem described is exactly what happens if the camera is randomly out of sync with the character position.

2 Likes

The solution for this bug is implemented in v4.5.0-test1 of Minie. v4.5.0-test1 is available from GitHub and Maven Central.

No changes were made to BetterCharacterControl. Instead, v4.5.0-test1 addresses the root cause of the “bouncing”. It does this by adding “contact filtering”. Contact filtering prevents impossible rigid-body contacts involving a HeightfieldCollisionShape or a MeshCollisionShape. Technical details available on request.

Contact filtering is enabled by default in v4.5.0-test1. Because it creates extra work for the physics engine, a Java API was added to disable it when it’s not needed:

        meshShape.setContactFilterEnabled(false);
        heightfieldShape.setContactFilterEnabled(false);

The bug does not affect characters on a ground that’s implemented using PlaneCollisionShape or any convex shape. However, characters might still “bounce off” a ground implemented using a CompoundCollisionShape or GImpactCollisionShape. Filtering those shapes looks to be a major effort, so it’s been deferred to a future release.

I’d appreciate feedback on this solution:

  • If you’ve experienced the bug, please check whether v4.5.0-test1 fixes it.
  • If you’re developing an app using Minie, please check v4.5.0-test1 for correctness and acceptable performance.
7 Likes

I updated minie to that version in my project and found no issues so far.

I’m only using the capsule collision shape for enemies and they don’t move that fast so I didn’t notice the problem before (I think I rarely saw them doing small hops but can’t be sure).

1 Like