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

RaycastHit Barycentric Coordinate

Discussion in 'DOTS Physics' started by CerebralDaemon, Oct 25, 2021.

  1. CerebralDaemon


    Feb 15, 2020
    In the non-ECS physics API, there is a barycentric coordinate inside RaycastHit, which provides a way to acquire the exact normal at the point of contact with a collider:

    Is there an equivalent way to achieve this using DOTS Physics? The RaycastHit returns a ColliderKey, which can be used in the PhysicsCollider to acquire the Collider and, using GetChild / GetLeaf, a ChildCollider, which has a RigidTransform, and this seems to have a position and a rotation; unfortunately I don't know enough about how the colliders and collisions are handled under-the-hood to know for sure if this is what I need, hence my question here.

    First of all, am I correct to think that the rotation inside the RigidTransform is the normal at that position of the Entity's Collider, and that I could use it alongside the hit's contact point similarly to the example code in the doc provided above? However, even if that's the case, I still only have one normal; how can I get my hands on what I need to make my calculations? I've seen that the Collider has a GetLeaves function that takes a collector; would that be the correct approach? What's the difference between a collider's childs and leaves?