Hi, I noticed in the transition from UCC2 to UCC3, TrajectoryObject went from using SingleCast(...) which did casts that returned the closest hit, to Cast(...) which can return multiple hits. However, these hits are not ordered by distance (https://forum.unity.com/threads/raycastnonalloc-sort-collision-from-furthest-to-closest.588013/). This results in a scenario where if I have a shield, my projectile can "hit" the shield as well as my character, and because only the first collider is used to assign m_RaycastHit, the projectile "hits" the character instead of the shield.
This can be fixed by adding a line:
after we perform the Physics.XXXCastNonAlloc. Additionally, if we do this, then we can replace the assignment for closestRaycastHit to the following:
This can be fixed by adding a line:
C#:
Array.Sort(m_CombinedRaycastHits, 0, hitCount, m_RaycastHitComparer);
after we perform the Physics.XXXCastNonAlloc. Additionally, if we do this, then we can replace the assignment for closestRaycastHit to the following:
C#:
var closestRaycastHit = m_CombinedRaycastHits[i];