1
\$\begingroup\$

We've got a character setup based around manually resolving collisions, and we're using bullet to do so. Our characters have a kinematic rigidbody to push things around, but their movement and positioning is done using a separate (pair caching) ghost object. Every physics tick we iterate over all contacts for that ghost and resolve collision either by depenetrating 100% when it's ground, or by depenetrating gradually/not at all with walls or other characters. We then apply our ghost's new position to the kinematic rigidbody so that can interact with other physics objects.

Unfortunately, when moving around a flat world made up of a bunch of coplanar blocks, when the characters moves from one block to another it will often do one of two things;

  • Fall through the cracks
  • Get bumped upward a significant distance (we're talking up to half a unit/meter with a character that is 2 units/meters tall)

enter image description here

Debugging this tells me sometimes these contact points are unexpected, and not something I want to resolve by depenetrating 100%. Gravity moving the character downward can result in a contact point that is closer to the side of the terrain block than the top, and it will give you a normal/distance accordingly (blue arrow). Resolving that with 100% depenetration will just push you in between the blocks, while not counteracting the gravity forces. This would explain the falling through the cracks. But I don't know why I sometimes get contact points with normals pointing straight up, but with a distance that would place the collider far above the ground (purple arrow).

I've come to the point where I feel like my only option to handle character movement like this is by not colliding with the ground at all, and just spherecast downwards at the character's position on the horizontal plane just to place it down on the ground properly.

Now obviously I want to get rid of this behaviour. And seeing how you don't see this happen in many games, I'm lead to believe others have solved this issue somehow. Has anyone here encountered similar issues, and how did you go about fixing them?

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.