Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Resolved Check*/Overlap* not working with mesh colliders?

Discussion in 'Physics for ECS' started by Lukas_Kastern, Jul 17, 2021.

  1. Lukas_Kastern

    Lukas_Kastern

    Joined:
    Aug 31, 2018
    Posts:
    97
    I'm not sure if this is a bug or by design but I can't seem to get the Check* and Overlap* extensions to work with mesh colliders.

    When I put the input collider on the edge of the mesh it works fine.

    This is a box collider with a sphere that turns red/green based upon the result of CheckSphere (hit detected):
    upload_2021-7-17_16-25-54.png

    This is the standard cube mesh used as a mesh collider (no hit detected):
    upload_2021-7-17_16-26-51.png

    And this is the same collider with the sphere touching the edge of the mesh (hit detected):
    upload_2021-7-17_16-27-34.png

    Any insights would be greatly appreciated :)
     
  2. hippocoder

    hippocoder

    Digital Ape

    Joined:
    Apr 11, 2010
    Posts:
    29,723
    Meshes do not have a volume so you will not be able to do an overlap check except at triangles. Pretty logical when you think about it. It should work fine with an actual box collider though.... such misleading screenshots at first glance.
     
    Lukas_Kastern likes this.
  3. Lukas_Kastern

    Lukas_Kastern

    Joined:
    Aug 31, 2018
    Posts:
    97
    Oh, that makes a lot of sense, for some reason I thought it would build volumes for me..
    Casting a ray from the inside to the outside seems to work and fits my use case so that is what I am going to go with.
    Thanks a lot!
     
    hippocoder likes this.
  4. hippocoder

    hippocoder

    Digital Ape

    Joined:
    Apr 11, 2010
    Posts:
    29,723
    If there's an equivalent to closest point on surface that probably can work with a distance check to sphere center and get around the mesh not having a volume.