Joins between mesh colliders generate physics issues(video)

Hi guys!

It’s a Simple 3d project in 2020.3.26f1 with no additional project settings setup
The scene is composed by:

  • A few static planes perfectly placed 10 units from each other with mesh collider.
  • 3 Cubes with Rigidbody, box collider and a simple behaviour applying continuous force in FixedUpdate

spanishpoorfairyfly

As you can see one cube dosn’t perform the collisión correctly. To what can it be due?

Cubes:
Cube

7910794--1008787--upload_2022-2-20_1-4-4.png

Behaviour:

public class continuousForce : MonoBehaviour
{
    public Vector3 force;
    Rigidbody rb;

    void Start()
    {
        TryGetComponent(out rb);
    }

    private void FixedUpdate()
    {
        rb.AddForce(force * rb.mass);
    }
}

Planes:
Planes 7910794--1008790--upload_2022-2-20_1-4-16.png
That’s all the scene

Scene Asset => Scene <=

Yep. That’s just how unity physics is. I’ve been battling this issue for years and years.

1 Like

I see:roll_eyes::roll_eyes:
I need for modular roads. What would you do? Any sugestion?
Thanks!

That depends on what’s going on your roads.

I haven’t used wheel colliders so i don’t know how they behave. Some car implementations use Rays for wheel physics which should work fine.

If you’re using balls or cylindrical shapes then they should roll over the gaps ok… maybe a small hop occasionally. If you reduce the bounciness of the road to zero then rolling objects will hop less on the gaps. Cube objects will stop dead though.

The higher gravity is the more this is an issue as the problem is that on that particular frame the physics object falls into the gap and resolves with the vertical face or edge of the road collider.

There is another thread somewhere where some people are playing with an experimental feature of unity physics where you can edit the contact points before the collision. Using that you could potentially detect the issue before the collisions and avoid the problem. I haven’t tried this though so I’m not familiar and i’m not sure what other problems would result.

One more option is to use the Havok unity physics package. although that’s not free for professional games. But i think havok has a settings which can combine meshes together and removes these edge collision issues.

Capsules, spheres and/or character controllers should provide better results. I’d suggest replacing your cubes with spheres or capsules and try again.

The actual cause of the problem is the vertical plane of the cube detecting a collision with the edge of the plane. Minimal numerical errors may be interpreted as the cube being barely tilted forwards, resulting in a hard contact with the edge. Spheres and capsules don’t have such problem.

Alternative solutions are using Raycasts or WheelColliders. These just project a ray vertically down each frame so they’re immune to collisions with the edges of the planes.