Search Unity

  1. The 2022.1 beta is now available for testing. To find out what's new, have a look at our 2022.1 beta blog post.
    Dismiss Notice

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

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

  1. Lukas_Kastern

    Lukas_Kastern

    Joined:
    Aug 31, 2018
    Posts:
    86
    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 Moderator

    Joined:
    Apr 11, 2010
    Posts:
    28,326
    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:
    86
    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 Moderator

    Joined:
    Apr 11, 2010
    Posts:
    28,326
    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.
     
unityunity