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. Join us on Dec 8, 2022, between 7 am & 7 pm EST, in the DOTS Dev Blitz Day 2022 - Q&A forum, Discord, and Unity3D Subreddit to learn more about DOTS directly from the Unity Developers.
    Dismiss Notice
  3. Have a look at our Games Focus blog post series which will show what Unity is doing for all game developers – now, next year, and in the future.
    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:
    95
    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:
    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:
    95
    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:
    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.