- Home /
Mesh Collider not colliding
Hello everyone! I am new to Unity, so I hope my question won't be out of place here. I have been searching for a solution to my problem, but haven't found anything that would solve it. Decided to give it a shot and ask.
So, what I am aiming for (in 2D) is to make different color squares fall down and stack one on top of another. I am using Meshes
to programmatically create squares. I create them in the Start()
method of a GameObject
I place in a scene. Since this object has a Rigidbody2D
, Unity does not allow me to attach a Mesh Collider
directly to it. Hence, I have added another GameObject
that sits within the first one and has a Mesh Collider
attached to it. In the code, where I create a Mesh
, I also assign it to the Mesh Collider
from the second GameObject
.
The collider is being created and I can see it (the green lines) when I run the project. However, it does not collide with any other colliders. For example, I have a bottom surface as a simple wide Box Collider, but my square just falls through it.
I assume, I am missing some Unity knowledge, but I am not sure where to look for answers any more. It would be great if someone could suggest a solution or point me where I could find an answer. Thanks!
Answer by konrad.bajtyngier · Feb 02, 2015 at 12:53 PM
I will answer my very silly question myself. Mesh Colliders work only within the 3D physics engine, so they cannot collide with my Box Collider 2D.
also, if someone is as unexperienced as me and thinks $$anonymous$$esh Colliders are a good choice in a project like that, don't use $$anonymous$$esh Colliders and simply add a Box Collider 2D in code:)