Check capcule collider completely inside a sphere
Hi all. In my 'for fun' project I worked on I have to check if collider is completely inside the sphere (explosion). Sphere definition is standart - center point and radius. I know about Physics.OverlapSphere but it returns both: overlapping colliders and colliders completely inside of the sphere.
I know how to deal with mesh colliders, box colliders and sphere colliders. But how can I accurately check capsule collider inside of a sphere or not? I'm a bit disappointed that Unity physics don't have such a trivial functionality.
Thanks in advance.
Answer by RecyclingBen · Mar 03, 2017 at 01:30 PM
A workaround could be to have another collider around the sphere and check if it is both inside of the sphere and not touching the colllider around it?
Someone also gives a better more precise idea here: http://answers.unity3d.com/questions/146260/check-if-collider-is-completely-inside-trigger.html
I'm not fully understand 'second collider' solution. It seems there is no way to check if colliders touching to each other statically. $$anonymous$$oreover even when they are moving OnTriggerEnter and OnCollisionEnter will not be fired if first collider moving from inside the second collider.
Your answer
![](https://koobas.hobune.stream/wayback/20220612112344im_/https://answers.unity.com/themes/thub/images/avi.jpg)