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

Queries hit backfaces doesn't seem to work

Discussion in 'Physics' started by josh_rake, May 8, 2017.

  1. josh_rake

    josh_rake

    Joined:
    Jan 4, 2017
    Posts:
    15
  2. josh_rake

    josh_rake

    Joined:
    Jan 4, 2017
    Posts:
    15
    How do I file a bug report?
    Because this thing is a hindrance
     
  3. janla

    janla

    Joined:
    May 8, 2013
    Posts:
    15
    Bump!
    Any news on this?? I need a way to count the in and out points of rays going through colliders...

    Thanks a lot!
     
  4. MarshCZA

    MarshCZA

    Joined:
    Apr 5, 2016
    Posts:
    6
    Adding to this because I had the same problem and couldn't find any solutions.

    Final Edit:
    The flag only works if the back face is the first thing to be hit for a given collider. So if you raycast from inside a cube you can hit the cube's back face. If you raycast from outside the cube the ray will hit a front face first and you will not see the back face hit as the ray leaves the cube.
    You can get a hit from the back of a plane as well.

    Useless for my needs.
     
    Last edited: May 1, 2020
  5. alppih

    alppih

    Joined:
    Jun 26, 2021
    Posts:
    2
    Massively late here but just wished to add to this as well, in case it helps someone - using Unity 2020.3.12f1, I got it working by using non-convex colliders. The moment the collider the ray shoots inside of was set as convex, it stopped working for me and couldn't recognize the backface.
     
    baruch1723 likes this.
  6. Abudharr

    Abudharr

    Joined:
    Jan 18, 2019
    Posts:
    1
    alppih was right: "I got it working by using non-convex colliders". I just deleted my box collider, added a mesh collider and unchecked Convex, thanks alppih.
     
  7. sorenandreasen

    sorenandreasen

    Joined:
    Mar 7, 2013
    Posts:
    11
    i have a terrain object "ground" (with a MeshCollider non-convex), and while the RaycastHitInfo is clearly indicating that this is the object that was indeed hit - if i have QueriesHitBackfaces enabled (something i use to avoid objects dipping below ground), the position of this hit is not touching the collider.. instead it is closer to the camera even though there are no other colliders there and - again - the collider being hit is still that ground object. could this have to do with the 3d modelling of my ground object somehow?
     
  8. unity_18smith111

    unity_18smith111

    Joined:
    Sep 15, 2022
    Posts:
    3
    a non-convex mesh collider is going to be essentially a mesh encapsulating whatever you are generating the meshcollider from.

    convex means that you can draw a line safely between any point in the graph/mesh
    and not intersect any other lines

    a box collider is a convex shape.
    so it kinda makes sense that your results didn't work with a box collider or with a convex mesh collider, yet it worked with a non-convex collider.