I am trying to use OverlapCapsuleNonAlloc to determine all enemy weapons that intersect with my character's CapsuleCollider at the same time. I want to get the contact point to trigger vfx in the right place. Is there someway I can find the contact point using OverlapCapsuleNonAlloc in Unity ?

  • 1
    \$\begingroup\$ When two shapes intersect in 3d space, then you don't have one single contact point. You have a whole 3d volume of overlapping space. So what you want can not work on a conceptual level. \$\endgroup\$
    – Philipp
    Oct 29, 2021 at 7:54
  • \$\begingroup\$ @Philipp i'm not sure if i understand well, but i did read somewhere that an OverlapSphere for example is just a bunch of Raycast, so normally it should be possible to get the hit Point, as Raycasting gives you that \$\endgroup\$
    – TensaDev
    Oct 29, 2021 at 8:01
  • \$\begingroup\$ I don't know where you read that, but I doubt that this is true. For collision detection between most 3d shapes there are far more efficient algorithms. But if you want to determine contact points, you can of course use your own raycasts. But then you of course need to decide from which point within your 3d volume you want to cast your ray(s). \$\endgroup\$
    – Philipp
    Oct 29, 2021 at 8:04
  • \$\begingroup\$ Have you considered using Collider.ClosestPoiint to choose the point on the weapon's collider that's closest to your capsule's center? It's not directly a contact point in most cases, but it gives you a good clue about the region of overlap. \$\endgroup\$
    – DMGregory
    Oct 29, 2021 at 12:13
  • \$\begingroup\$ @DMGregory yea, i was thinking of it and was too hesitant in case 10 ennemies attack at the same time it might be not good to go. but, since you think too its likely to work, i'll just try that. I'll answer back my question if that works well :) \$\endgroup\$
    – TensaDev
    Oct 29, 2021 at 15:27

1 Answer 1


overlapResults[i].ClosestPoint(yourGameObject.position) works pretty well, but consider specifying the Layer you are targeting in your overlap ^^


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .