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

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

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?

Hey buddy! Back again :sunglasses:

Did you already check this?

1 Like

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

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?

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:

you end up here:

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

1 Like

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.

YES!

Shortly speaking - bounding boxes.

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
c. Usually camera.minZ = 0.1 (minimum) gives the best experience with collisions.

2 Likes

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

1 Like

Here is a small example- 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 :slight_smile:

3 Likes

You rule! :slight_smile:

Thanks so much, labris!

2 Likes

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.
3 Likes

I meant I am back again to try to help and not you :sunglasses:

1 Like

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. :cold_sweat:

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

The hype didn’t reach me because I didn’t hear about Metaverse until now :blush: :speak_no_evil: :see_no_evil: :hear_no_evil:

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! :vulcan_salute:

1 Like

@roland and @labris you are the best :slight_smile:

3 Likes

I’m still just scratching the surface though :upside_down_face: :ghost: but even solving the simple problems, answering easy questions and helping dudes is quite satisfying :vulcan_salute:

1 Like