Search Unity

  1. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice
  2. Unity is excited to announce that we will be collaborating with TheXPlace for a summer game jam from June 13 - June 19. Learn more.
    Dismiss Notice
  3. Dismiss Notice

Question how to get Accurate Distance Query?

Discussion in 'Physics for ECS' started by filod, Jan 23, 2024.

  1. filod

    filod

    Joined:
    Oct 3, 2015
    Posts:
    226
    consider this:

    calc a ColliderDistanceInput with BoxCollider to a plane, the CalculateDistance return only one DistanceHit, and also the hit.Position is not stable, what i want is: it will return 8 hits (every vertex in a boxcollider), so i can use the hits to acheive something like "conform a box onto a wall" like function.

    Any thoughts?
     
  2. FaithlessOne

    FaithlessOne

    Joined:
    Jun 19, 2017
    Posts:
    330
    While I am not sure whether in works like you want, but it sounds like you should give the MeshCollider a try. Bounding Volumes usually not return multiple hits, while a MeshCollider for your box can do that, at least when a raycast crosses the box. But I am not sure what happens in your plane to box collision scenario and whether it really returns 8 hits or not.
     
  3. filod

    filod

    Joined:
    Oct 3, 2015
    Posts:
    226
    thx, but that's not viable, because the collider i cast might be any type. (a building system like valheim), right now i have a workaround, but it's really dirty and limited, i retrive all vertices of the convex hull, and then cast the verts myself.