The colliders colliding with each other and I don't want

Hello everyone,
I have this bus and I want to use a wheel colliders to move it, so I added a box collider and Rigidbody to the GameObj this box collider it will be responsible for the bus interacting with the outside world like road and other cars


Here a mesh collider this is for the player so he can move inside the bus

And here I declared to unity that I don’t want the layers with Interior to ignore the layers in exterior layer
Declaring that exterior layers should not clash with interior layers
I gave the object that carry the box collider a exterior layer and the object that carry the mesh collider a interior layer,
but for some reason the bus fly high when I start the game.

Do you have any idea why this happen?
Thanks.

The interior collider is not the problem here, as it has no rigidbody on its own. Does anything inside the exterior collider have its own rigidbody that is set to kinematic? What about the player, does he spawn inside the bus? If a kinematic rigidbody is the child of a non-kinematic rigidbody and overlapping with its collider, this type of behavior will happen.

As you can see in the picture the parent GameObj is the only object that have a rigidbody and it not kinematic.
The player have a character controller, and the player initial position is inside the bus

The player controller works similar to a kinematic rigidbody, at least in this situation, and if he is inside the exterior box collider, this means they interact with each other. As far as Unity is concerned, a box collider is solid and it will try to push out anything inside that is affected by physics, or if the collider itself has a rigidbody, it will try to get away from these objects. However, if the objects are children of the collider itself and have a kinematic rigidbody or a player controller, this is not possible, as the child objects will move together with the parent object, resulting in unintended behavior. You could exclude the player from colliding with the exterior as well, if that works for you.

However, if you want the player to be able to move inside the bus while it drives, you will get a different problem, because your interior mesh collider is not convex, so it will not work with the rigidbody of the parent object. Concave colliders only work with kinematic rigidbodies or objects with no rigidbody at all. You would have to build an approximated collider out of multiple box colliders for this to work, and then not use a single large box collider for the interior, but one for each side.

Untick Interior and try again

As you see here I declared to unity that the interior should only collide with the player and the exterior should not collide with the player and the interior.
the result of this is the player do not colliding with both the interior and exterior.
I tired removing the rigidbody from the parent no wired result the player stay in bus and the bus don’t fly or something. but I need the rigidbody because I want to move the bus with the wheel colliders

That is probably because the interior collider is not convex, as non-kinematic rigidbodies only work with convex colliders, and the interior is treated as part of the parent rigidbody’s collider, because it doesn’t have one itself.

You need to construct a compound collider out of convex colliders, like box colliders:
Unity - Manual: Introduction to compound colliders (unity3d.com)
Unity - Manual: Create a compound collider (unity3d.com)

1 Like

Thanks, I will try this compound collider. but is there no way other then this even if I made it convex the player don’t collide with it

It didn’t work I used the compound collider


The bus fly and rotate

I worked I just needed to raise the mass from 1 to 2000