Title: Issues with objects passing through each other in Unity
Tags: unity3d
Question: I was creating a simulation that involved a rotating bucket drum that is supposed to go through rough soil. To simulate this, I made a project in Unity and imported that CAD design of the drum and added in a bunch of spheres for the dirt. Then, I added a mesh collider to the drum, sphere colliders to the dirt, and rigidbodies to everything. I also turned on the continuous dynamic collision detection on both the dirt and the drum, and made sure to turn of isTrigger and isKinematic in both. But whenever I run the sim, the same issue pops up: the spheres just go directly through the drum and nothing I can do will fix it. I've tried looking at other threads but all of those solutions don't work. Can I get some help? Thanks.

Image of the drum before colliding with the spheres

Image of the drum in the middle of the spheres with nothing disturbed

Image of the components on the rotating drum

Image of the components on the spheres (All of them have the same setup)

Code:

```using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class RotateScript : MonoBehaviour
{

    public float thrust = 0.1f;
    public float torque = 0.5f;
    public Rigidbody rb;

    void Start()
    {
        rb = GetComponent<Rigidbody&gt;();
        rb.AddForce(0, 0, -thrust, ForceMode.Impulse);

    }

    private void FixedUpdate()
    {
        float turn = Input.GetAxis("Horizontal");
        rb.AddTorque(transform.up * torque * turn);

        if(Input.GetKeyDown(KeyCode.W))
        {
            rb.AddForce(0, 0, (thrust * 2), ForceMode.Impulse);
        }

        if(Input.GetKeyDown(KeyCode.S))
        {
            rb.AddForce(0, 0, (-thrust * 2), ForceMode.Impulse);
        }
    }
}
```

Comment: Perhaps try making the mesh collider convex. Mesh colliders can't interact with anything if they aren't convex

Comment: What are the settings for the rigidbodies on the dirt? From the image it looks like they're all floating in midair which suggests to me that you may have frozen their position.

Comment: Just found a [link](https://docs.unity3d.com/ScriptReference/Rigidbody-collisionDetectionMode.html) that states: "Continuous Collision Detection is only supported for Rigidbodies with Sphere-, Capusle- or BoxColliders." This means that your dirt spheres can't detect the mesh collider on the rotating bucket drum. Try switching the collision detection mode to discrete for all the objects.

Comment: Just to narrow things down, try changing the bucket drum's collider to a box collider and see if they can interact then. If they can interact then the problem is likely with the mesh collider, if they still can't interact then the problem is likely a problem with the rigidbody. I can't see anything wrong with your code but just to be sure, you should also try using the scene window to manually move the drum into the dirt and see if they interact. Could you also show some pictures of the components on both the drum and the dirt gameobjects so I can see the setup?

Comment: Have you tried a combination of these suggestions? I.e. Make the mesh collider convex and make sure that the rigidbodies for everything are set to discrete collision detection? I can see in the images that the drum's rigidbody is still set to continuous collision detection. I don't know if you changed it back to that because you put a box collider on or not but it is something that does NEED to be set to discrete for the mesh collider. If none of this is working, then you might just have to use compound colliders(lots of smaller colliders that will roughly be the same shape as the drum)

Comment: Thanks for the quick response! I tried doing that but it didn't seem to work. Any other ideas?

Comment: The rigidbodies don't use gravity and are not kinematic, and their mass is 1. Their collision detection is set to continuous.

Comment: No, that didn't seem to work. The exact same behavior happened as last time, maybe there's another factor that's screwing everything up?

Comment: When I changed the collider from the mesh to a standard box, it interacted with the dirt. If I move the drum into the dirt in the scene view, nothing happens. I also updated the images in the original post to include the components on the gameobjects.



{'source': 'StackExchangeDataset', 'subset': 'stackoverflow.com', 'metadata': {'AnswerCount': 0, 'CommentCount': 9, 'ContentLicense': 'CC BY-SA 4.0', 'CreationDate': '2020:00:04/05/20', 'FavoriteCount': None, 'PostTypeId': 1, 'Tags': '<unity3d>', 'Title': 'Issues with objects passing through each other in Unity', 'ViewCount': 94, 'id': 61050150, 'user_AboutMe': '', 'user_AccountId': 18185093.0, 'user_DisplayName': 'Teja Koduru', 'user_Reputation': 11.0, 'user_Views': 12.0, 'user_id': 13232007.0}}