# Does Babylon use bounding boxes for collision-checking on complex meshes?

**URL:** <https://forum.babylonjs.com/t/does-babylon-use-bounding-boxes-for-collision-checking-on-complex-meshes/26831>\
**Category:** Questions\
**Created:** [January 17, 2022, 6:51am UTC](https://forum.babylonjs.com/t/does-babylon-use-bounding-boxes-for-collision-checking-on-complex-meshes/26831 "2022-01-17T06:51:11Z")\
**Posts on this page:** 16\
**Page:** 1

<div class="post-metadata">

**Author:** ![VerifiedTinker](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/verifiedtinker/32/20439_2.png) [@VerifiedTinker](https://forum.babylonjs.com/u/VerifiedTinker)\
**Post date:** [January 17, 2022, 6:51am UTC](https://forum.babylonjs.com/t/does-babylon-use-bounding-boxes-for-collision-checking-on-complex-meshes/26831/1 "2022-01-17T06:51:11Z")

</div>

I noticed today the Inspector lets you see bounding boxes of meshes.

 ![image](https://us1.discourse-cdn.com/flex024/uploads/babylonjs/original/3X/2/e/2ee9261117b146efc1416e8ca76d3b876325209b.jpeg)

Does Babylon use those for collision-checking?

In other words, do I need to wrap the walls and other collideables of my environment in invisible “collider” boxes, or can I directly enable `checkCollisions` on them? Does Babylon use the actual, complex mesh for collisions, which can be expensive, or the simple bounding cube?

And is it the same with mesh-against-mesh collisions as camera-against-mesh ones?

---

<div class="post-metadata">

**Author:** ![roland](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/roland/32/38940_2.png) [@roland](https://forum.babylonjs.com/u/roland)\
**Post date:** [January 17, 2022, 6:59am UTC](https://forum.babylonjs.com/t/does-babylon-use-bounding-boxes-for-collision-checking-on-complex-meshes/26831/2 "2022-01-17T06:59:52Z")

</div>

Hey buddy! Back again 🕶

Did you already check this?

> **[Introduction to Developing a System For Collisions | Babylon.js Documentation](https://doc.babylonjs.com/guidedLearning/workshop/Collide_Intro)**
>
> A collision system built using justBabylon.js code with no physics engines

---

<div class="post-metadata">

**Author:** ![VerifiedTinker](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/verifiedtinker/32/20439_2.png) [@VerifiedTinker](https://forum.babylonjs.com/u/VerifiedTinker)\
**Post date:** [January 17, 2022, 7:11am UTC](https://forum.babylonjs.com/t/does-babylon-use-bounding-boxes-for-collision-checking-on-complex-meshes/26831/3 "2022-01-17T07:11:41Z")

</div>

Hey, that was fast! I took the liberty to make another post so soon since it’s a simple yes-or-no question. 😅

Yeah, I did see that page, though I skimmed it and left, figuring a custom physics system wasn’t what I was looking for. I admit, having now taken a longer look, I still don’t understand.

I’m guessing the PG is how you’d go about achieving bounding-box collisions? So, that’s not how it works by default?

---

<div class="post-metadata">

**Author:** ![roland](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/roland/32/38940_2.png) [@roland](https://forum.babylonjs.com/u/roland)\
**Post date:** [January 17, 2022, 7:25am UTC](https://forum.babylonjs.com/t/does-babylon-use-bounding-boxes-for-collision-checking-on-complex-meshes/26831/4 "2022-01-17T07:25:49Z")

</div>

I don’t know the exact answer, so we should wait for a response from a more experienced Babylonian. However a quick examination of the source code here:

> <https://github.com/BabylonJS/Babylon.js/blob/d7a6b0ad11f33859af56a3d3531aed6e540f8f8b/src/Meshes/abstractMesh.ts#L1729>

you end up here:

> <https://github.com/BabylonJS/Babylon.js/blob/d7a6b0ad11f33859af56a3d3531aed6e540f8f8b/src/Collisions/collider.ts#L6>

It’s a common technique to use dummy meshes for collisions though.

---

<div class="post-metadata">

**Author:** ![labris](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/labris/32/12576_2.png) [@labris](https://forum.babylonjs.com/u/labris)\
**Post date:** [January 17, 2022, 7:34am UTC](https://forum.babylonjs.com/t/does-babylon-use-bounding-boxes-for-collision-checking-on-complex-meshes/26831/5 "2022-01-17T07:34:44Z")

</div>

> [@VerifiedTinker](#):
>
> In other words, do I need to wrap the walls and other collideables of my environment in invisible “collider” boxes,

If your model has some defects you may need to use some invisible meshes to correct them (if you cannot edit the model, for example). Sometimes invisible planes are the best choice for stairs etc.

> [@VerifiedTinker](#):
>
> can I directly enable `checkCollisions` on them

YES!

> [@VerifiedTinker](#):
>
> Does Babylon use the actual, complex mesh for collisions, which can be expensive, or the simple bounding cube?

Shortly speaking - bounding boxes.

> [@VerifiedTinker](#):
>
> And is it the same with mesh-against-mesh collisions as camera-against-mesh ones?

Camera ellipsoid against mesh.

**a.** Sometimes one may need to use custom ellipsoid mesh for the camera collisions (for example, to use moveWithCollisions function which works only for meshes).  
**b.** For the final tuning or in case of glitches you may play with `collisionRetryCount` - [Babylon.js docs](https://doc.babylonjs.com/typedoc/classes/babylon.mesh#collisionretrycount)  
**c.** Usually camera.minZ = 0.1 (minimum) gives the best experience with collisions.

---

<div class="post-metadata">

**Author:** ![roland](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/roland/32/38940_2.png) [@roland](https://forum.babylonjs.com/u/roland)\
**Post date:** [January 17, 2022, 7:36am UTC](https://forum.babylonjs.com/t/does-babylon-use-bounding-boxes-for-collision-checking-on-complex-meshes/26831/6 "2022-01-17T07:36:58Z")

</div>

Aaaand we have the precise answer… 🙂 Damn, I love this community!

---

<div class="post-metadata">

**Author:** ![labris](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/labris/32/12576_2.png) [@labris](https://forum.babylonjs.com/u/labris)\
**Post date:** [January 17, 2022, 7:39am UTC](https://forum.babylonjs.com/t/does-babylon-use-bounding-boxes-for-collision-checking-on-complex-meshes/26831/7 "2022-01-17T07:39:24Z")

</div>

Here is a small example- [https://playground.babylonjs.com/#0VHCTL#14](https://playground.babylonjs.com/#0VHCTL#14)  
Model is taken from Sketchfab. Just several lines of code and you have a game level ready… for something 🙂

---

<div class="post-metadata">

**Author:** ![roland](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/roland/32/38940_2.png) [@roland](https://forum.babylonjs.com/u/roland)\
**Post date:** [January 17, 2022, 7:45am UTC](https://forum.babylonjs.com/t/does-babylon-use-bounding-boxes-for-collision-checking-on-complex-meshes/26831/8 "2022-01-17T07:45:38Z")

</div>

You rule! 🙂

---

<div class="post-metadata">

**Author:** ![VerifiedTinker](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/verifiedtinker/32/20439_2.png) [@VerifiedTinker](https://forum.babylonjs.com/u/VerifiedTinker)\
**Post date:** [January 17, 2022, 7:47am UTC](https://forum.babylonjs.com/t/does-babylon-use-bounding-boxes-for-collision-checking-on-complex-meshes/26831/9 "2022-01-17T07:47:27Z")

</div>

Thanks so much, labris!

---

<div class="post-metadata">

**Author:** ![labris](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/labris/32/12576_2.png) [@labris](https://forum.babylonjs.com/u/labris)\
**Post date:** [January 17, 2022, 8:04am UTC](https://forum.babylonjs.com/t/does-babylon-use-bounding-boxes-for-collision-checking-on-complex-meshes/26831/10 "2022-01-17T08:04:41Z")

</div>

Two more things for the best user collision experience.

1. Sometimes collisions don’t work on some meshes (one can pass through them). Usually it means that these meshes have incorrect (usually inverted) normals.
2. In some cases (it also depends on camera ellipsoid size) one may stuck to mesh and lost the ability to move. Check this spot in 3D editor, and if there is no way to correct it on model level, use invisible planes or meshes to avoid bad user experience.

---

<div class="post-metadata">

**Author:** ![roland](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/roland/32/38940_2.png) [@roland](https://forum.babylonjs.com/u/roland)\
**Post date:** [January 17, 2022, 8:38am UTC](https://forum.babylonjs.com/t/does-babylon-use-bounding-boxes-for-collision-checking-on-complex-meshes/26831/11 "2022-01-17T08:38:15Z")

</div>

> [@VerifiedTinker](#):
>
> I took the liberty to make another post so soon since it’s a simple yes-or-no question. 😅

I meant I am back again to try to help and not you 🕶

---

<div class="post-metadata">

**Author:** ![roland](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/roland/32/38940_2.png) [@roland](https://forum.babylonjs.com/u/roland)\
**Post date:** [January 17, 2022, 8:39am UTC](https://forum.babylonjs.com/t/does-babylon-use-bounding-boxes-for-collision-checking-on-complex-meshes/26831/12 "2022-01-17T08:39:38Z")

</div>

What’s the project you’re working on? A game?

---

<div class="post-metadata">

**Author:** ![VerifiedTinker](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/verifiedtinker/32/20439_2.png) [@VerifiedTinker](https://forum.babylonjs.com/u/VerifiedTinker)\
**Post date:** [January 17, 2022, 8:47am UTC](https://forum.babylonjs.com/t/does-babylon-use-bounding-boxes-for-collision-checking-on-complex-meshes/26831/13 "2022-01-17T08:47:23Z")

</div>

> [@roland](#):
>
> What’s the project you’re working on? A game?

The announcement of the Metaverse has generated an unreal amount of hype, and everyone, including my client, is trying to cash in. So, basically, I’ve got to create a web-based, networked world that should work on both PC and mobile, with an optional VR mode for both platforms, and a 3D eCommerce interface + store customization. 😰

Hence why I went with Babylon. I’m most at home with Unity, but its web exports leave much to be desired.

---

<div class="post-metadata">

**Author:** ![roland](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/roland/32/38940_2.png) [@roland](https://forum.babylonjs.com/u/roland)\
**Post date:** [January 17, 2022, 9:22am UTC](https://forum.babylonjs.com/t/does-babylon-use-bounding-boxes-for-collision-checking-on-complex-meshes/26831/14 "2022-01-17T09:22:08Z")

</div>

The hype didn’t reach me because I didn’t hear about Metaverse until now 😊 🙊 🙈 🙉

Good luck and have as many questions as you wish! I am a newbie here and switched from Unity to BabylonJS for the same reason as well, but will try to help you to solve your problems every time you face them. It’s a cool and nice way to gain experience for me too! 🖖

---

<div class="post-metadata">

**Author:** ![sebavan](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/sebavan/32/57_2.png) [@sebavan](https://forum.babylonjs.com/u/sebavan)\
**Post date:** [January 17, 2022, 9:37pm UTC](https://forum.babylonjs.com/t/does-babylon-use-bounding-boxes-for-collision-checking-on-complex-meshes/26831/15 "2022-01-17T21:37:15Z")

</div>

@roland and @labris you are the best 🙂

---

<div class="post-metadata">

**Author:** ![roland](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/roland/32/38940_2.png) [@roland](https://forum.babylonjs.com/u/roland)\
**Post date:** [January 18, 2022, 1:57am UTC](https://forum.babylonjs.com/t/does-babylon-use-bounding-boxes-for-collision-checking-on-complex-meshes/26831/16 "2022-01-18T01:57:57Z")

</div>

I’m still just scratching the surface though 🙃 👻 but even solving the simple problems, answering easy questions and helping dudes is quite satisfying 🖖
