2

The Problem: Mesh colliders on some rigidbody objects are passing through colliders on other objects.

Things I have tried:

With the assumption A is a GameObject with a RigidBody attached and B is a normal GameObject with a collider.

  • Give A a convex mesh collider
  • Give A a non-convex mesh collider
  • Give B a convex mesh collider
  • Give B a non-convex mesh collider
  • give B a box collider
  • give B a convex mesh and box collider
  • give B a non-convex mesh and box collider
  • Adjusting the weight of the rigidbody

I have tried all of these in all combinations of A and B.

In addition,

  • Colliders are not marked as triggers
  • All objects are on the default layer (0)
  • Checking isKinematic; doing this seemed to make gravity stop affecting the object, so I have left it as false.

Constraints: I want A to use a mesh collider since most of the objects involved are moderately complex, and fitting other colliders to them would take a while.

Weird Behaviour: I have some objects with both rigidbody and convex mesh collider where the collision is working fine with a non-convex mesh collider. This is inconsistent with other gameobjects. The objects have all of the same settings.

I am using unity version 2019.3.11f1 if that is relevant.

The object being used are from this package. Specifically, the filing cabinet with rigidbodies on the drawers works fine. The desk, office chair, pen, and open laptop all fall through the "floor" (a cube with all of the above colliders tested on it).

Jacob H
  • 864
  • 1
  • 10
  • 25

4 Answers4

2

Do you have 'isKinematic' checked on the objects with rigidbodies that are going through other colliders? If so uncheck it so that external forces affect it.

edit you also need to click convex on the mesh colliders if they are colliding with other mesh colliders, Convex Mesh Colliders are limited to 255 triangles, are the objects that are not passing through have more than 255 triangles in geometry?

vasmos
  • 2,472
  • 1
  • 10
  • 21
  • I will update my answer. I have left isKinematic unchecked. When I tried checking it, gravity seemed to stop affecting the object. – Jacob H May 06 '20 at 02:27
  • 1
    you want it unchecked – vasmos May 06 '20 at 02:28
  • yes sorry if that was not clear, it is not checked. – Jacob H May 06 '20 at 02:29
  • can u paste a screenshot of your components on the objects that are passing through? – vasmos May 06 '20 at 02:32
  • [rigidbody object](https://i.stack.imgur.com/Sfgx3.png), [non rigidbody object](https://i.stack.imgur.com/jK0aa.png). Note that I have tried all combinations of convex and non-convex in the colliders pictured. I have also tried disabling the teleport script shown. – Jacob H May 06 '20 at 02:42
  • I think they all have < 255 triangles, though I didn't check them all. The laptop specifically only has 78, and it is not working, even with convex checked on both colliders. – Jacob H May 06 '20 at 02:53
  • does the object its colliding with also have convex checked and < 255 triangles? – vasmos May 06 '20 at 02:57
  • Yes, the colliding object is just a cubes so it should have few triangles, and I have tried with and without convex checked. I have also tried using a box collider to no avail. – Jacob H May 06 '20 at 03:00
  • how are you colliding? are you grabbing it in vr and moving it around? – vasmos May 06 '20 at 03:01
  • I don't get the chance to grab it, it falls through the floor before I can. – Jacob H May 06 '20 at 03:03
  • is it supposed to have gravity enabled on the rigidbody? – vasmos May 06 '20 at 03:11
  • Yes, I want gravity to affect the rigid body objects – Jacob H May 06 '20 at 03:32
  • will the pen and other objects fall through the filing cabinet as well or do they collide with them? – vasmos May 06 '20 at 04:10
  • Objects with a convex mesh collider sit on top of the cabinet and do not pass through. – Jacob H May 06 '20 at 14:19
  • can you screenshot your floor collider? this is the only one that is not working properly then right? – vasmos May 06 '20 at 14:31
  • 1
    I just managed to get it working. I added a plane with a mesh collider on top of my teleport area. It seems like the SteamVR TeleportArea script was interfering with the colliders. Then I gave all objects with rigidbodies convex mesh colliders – Jacob H May 06 '20 at 14:34
  • Should be mentioned, if you are using a NavMesh and have dynamic objects in the scene, that you would like to be avoided, you need to use a NavMesh Obstacle on those objects with Carve enabled: https://docs.unity3d.com/Manual/class-NavMeshObstacle.html – aggaton Sep 10 '21 at 23:16
1

I am Assuming you have set your Collision Detection to Discrete In your gameObject's RigidBody, if so, please make sure to select Collision Detection to Continuous In your gameObject's RigidBody.

Reason Why this is not working

  1. You are trying to use collision that has (speed > your Computer's frame speed) so, the frame is not catching the collider properly some time catches and some time fails to catch.

  2. You are moving your GameObjects with tranform.translate or position etc. If so then make sure to use Rigidbody Related function for Positioning, rotating.

Solution Image For First Problem

webLacky3rdClass
  • 659
  • 10
  • 27
Karan Sahu
  • 31
  • 5
  • Keep in mind Rigidbody.position will NOT work -- it will still move you through the colliders at high speed. You have to use Rigidbody.MovePosition – SavedByZero Aug 24 '23 at 20:17
1

This seems to be a common big problem, and I have been struggling with the same issue for days, and have finally fixed it, so am feeling like I should highlight one important thing:

move Rigidbody via MovePosition, not via just changing its position field directly, nor via changing position of GameObject holding it.

Changing position via "wrong" ways will "teleport" your rigidbody, physics won't fully work on it in that case.

Fyodor
  • 2,793
  • 4
  • 21
  • 24
0

I'm assuming -you game object which contain the mesh component is very small ( bellow 0.7 size(x,y,z) so the game engine is little difficult to detect it)

and also

  • for the colliding objects at-least one rigid-body component must be attach to one object