Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more..
    Dismiss Notice
  3. Dismiss Notice

Help with Mesh Collider

Discussion in '2D' started by scossgrove, Jul 8, 2022.

  1. scossgrove

    scossgrove

    Joined:
    Jan 6, 2016
    Posts:
    23
    Hi,


    I have a character with a circle collider on it with the following settings:
    upload_2022-7-8_15-40-31.png

    From the image below you can see the collider circle around the player:

    upload_2022-7-8_15-40-19.png

    Then I have a dynamic mesh created and set against a mesh collider:
    upload_2022-7-8_15-42-7.png
    you can see the collider mesh below:
    upload_2022-7-8_15-41-48.png

    My issue is that I can move straight throw the mesh collider.

    The player is moved using a rigidBody2 and the velocity.

    Can anyone tell me what I am doing wrong here?

    Thanks in advance
     
  2. MelvMay

    MelvMay

    Unity Technologies

    Joined:
    May 24, 2013
    Posts:
    10,533
    The MeshCollider is a 3D physics collider. The CircleCollider2D is a 2D physics collider. They don't interact, they are completely different systems.

    Also, don't go modifying the Transform when using 2D physics. Use a Rigidbody2D and its API to cause movement, this is how 2D physics works. Colliders are attached to Rigidbody2D. A Rigidbody2D has three body-types to choose from too.

    I would suggest following some tutorials here or using Unity Learn for more information.
     
  3. scossgrove

    scossgrove

    Joined:
    Jan 6, 2016
    Posts:
    23
    OK So what type of collider to I used with a mesh in 2d?
     
  4. MelvMay

    MelvMay

    Unity Technologies

    Joined:
    May 24, 2013
    Posts:
    10,533
    2D physics cannot use a 3D mesh, it's 2D. There's a PolygonCollider2D that essentially produces a similar thing from outlines dynamically but as I mentioned above, there's plenty of tutorials online for more info.