No Seamless Collider?

Hey hey, it’s me again :slight_smile:

We encountered a problem when working with collider and round objects. We noticed that a rolling object starts “jumping” when moving across multiple collider. I created a small test scene, in which you can move along the path via WASD and the arrow keys. All floor tile collider have halfextends of [0.5, 0, 0.5] and are 1 unit apart from each other. If you roll across the plane, you notice that the ball start bouncing.

Now this is obviously an exaggeration of how our levels are gonna be build, but even when using bigger collider, the sphere starts jumping when rolling across multiple collider. I also tried slightly overlapping the collider, but with no success.

How can I prevent this behaviour? Is there a setting somewhere, like in Unity the “Contact Offset” that I can use to smooth the collision detection?



I can confirm this, I encountered the same on a bowling style game, the jumping when the ball would roll on a surface belonging to a different rigidbody.

I wasn’t able to find a fix so I implemented a nasty workaround: monitor the height of the ball per frame … and if it matches a jumping pattern cancel any vertical linear speed change. Of course this worked for that game only, it’s not a generic solution.

I wonder if it’s related to some floating point inaccuracy :thinking: I’ve had similar problems with Unity on this as well with tile maps

The Contact Offset sounds good for a feature request on the engine.

1 Like

Do you think this is the fault of some part in the engine, and not a part of Ammo.js?

Hard to say without looking it TBH. It could be a combination of both?

Unity seems to provide a “Default Contact Offset” value to fix this, maybe ammo provides something similar, which can be exposed though the settings menu?

Feature request added:


Some info I found when Googling:


The issue I think with using the contact offset solution from Unity is that in Bullet I believe the equivalent is setting the collision margin, but for sphere bodies the entire collision space is the collision margin and Bullet warns against changing it for objects in which that’s the case. Here is the relevant excerpt from the Bullet user manual (bottom of page 20)

“Bullet uses a small collision margin for collision shapes, to improve performance and reliability of the
collision detection. It is best not to modify the default collision margin, and if you do use a positive
value: zero margin might introduce problems. By default this collision margin is set to 0.04, which is 4
centimeter if your units are in meters (recommended).
Dependent on which collision shapes, the margin has different meaning. Generally the collision
margin will expand the object. This will create a small gap. To compensate for this, some shapes will
subtract the margin from the actual size. For example, the btBoxShape subtracts the collision margin
from the half extents. For a btSphereShape, the entire radius is collision margin so no gap will
occur. Don’t override the collision margin for spheres. For convex hulls, cylinders and cones, the
margin is added to the extents of the object, so a gap will occur, unless you adjust the graphics mesh
or collision size. For convex hull objects, there is a method to remove the gap introduced by the
margin, by shrinking the object. See the Demos/BspDemo for this advanced use.”


Interesting topic. I’ve met this issue when I was making an infinite scroller a while back. If you keep running forward, you can notice a slight camera bump when the player collider moves from one tile to the next.

I think this is also related to the issue that @Albertos has in his topic about crosshair problem. His ground is assembled from box colliders. The crosshair is always oriented to face the normal direction, but sometimes erratically turns on a seemingly flat ground.

Originally, I thought this might be due to the fact that the bullet engine adds a small margin to the box collision shape. As @kanet pointed, it is about 0.04. This rounds the corners of the box shape, so they are not sharp. If two boxes (rigidbodies with box shaped colliders) are placed right next to each other, then there should be a thin crevise on the edge. In theory.

What I’ve tried:

  1. I tried to change the margin of the box shapes to 0, to remove the presumable crevise. Unfortunately, it didn’t help. The ball still jumps off the edges.
  2. Then, I thought perhaps this is the way the engine calculates the box shape and having the height of the box as zero messes it up. Changing all sides to equal didn’t help. The result was the same.
  3. I’ve also tried to add a custom collision shape - a plane, which is not available through editor. I used btBvhTriangleMeshShape, which is good for custom static shapes. I basically created two triangles placed together, forming a square plane. Then used that plane to form a field of tiles, like in the original example of @AliMoe, placing field next to the one made from boxes. Unfortunately, that didn’t help either - the ball keeps jumping.