Hacking The Rigid Body Seams Problem

In my previous post, I described how I wrote a custom character controller to try to fix the rigid body seams problem that I was experiencing in my game.

I'm not pressing jump - the character is catching on seams between cubes meshes.

I'm not pressing jump - the character is catching on seams between cubes meshes.


The problem is basically this: When a rigid body moves overtop of a stack of cubes, the collision resolution causes the character to jitter and jump and behave generally intoxicated. It seemed to me at the time that there were 2 possible solutions. The first solution was to merge the cubes into a single mesh and use a mesh collider. I made a test mesh and my character jittered over the seams in the mesh. So that solution was out. The second solution that I considered was to write a custom character controller, which I describe in this post. (note: I'm working on merging the cubes into a single mesh that will not have seams - but I've been struggling with it).

While falling asleep one night last week, I came up with a third solution to the seams problem. A hacky solution. A quick solution. In this solution, I would not have to remove the rigid body. I could keep my movement and jumping and everything else intact, and fix the seams problem using this different approach.

The basics of the idea are this: when the character contacts the seams, switch the physics layer of the character to a layer that doesn't collide with the seams, and instead collide with a large box collider that envelopes the seams. Conversely, when the character loses contact with the seams, the character will switch back to it's regular layer and fall through the large box collider. This also has the added bonus of massively simplifying the collision calculations that the system will be performing.

I tried it, and it works great in my game.

BOOM. SOLVED.

Well, not quite, this solution has an as of yet not apparent problem - what if someone blows away the top layers of a cube stack? Then the large Box Collider will cause the character to float atop the former surface of the stack. Currently, this is almost impossible to do in the game, simply because of the design of the levels. A possible band-aid is just in level design: the cube stacks that are tall enough for this to occur, can be made hollow, and that way if they blow off the top layer, there is no layer below to stand on.

As described in the character controller post, the ultimate (work in progress) solution is going to be to use a custom character controller on top of a merged mesh. The character controller will prevent any seam-jitter and the merged mesh will be easier on the rendering and physics system.

EDIT: I may or may not go with a custom character controller - it's going to be hard to write and may not benefit the game. But I will find an algorithm to merge these meshes without creating seams. I'll update this post when I finish that algorithm.