Is Babylonjs currently supporting physics for parent or child meshes?

I am trying to set physics for my parent and child mesh, but it is not working.
Are there any physics that supports this feature?

I think not, but let me check with @Cedric

It depends on the type of parenting you want. If it’s a static link, then you can create a compund

If it’s a dynamic link, then you can create a joint

1 Like

I have tried with joints before, but it didn’t work as I wanted. The best solution for my case was merging the meshes, and it worked well, but sometimes merge problems were created because of meshes with different materials and different textures even though the multimaterial was set to true.
The compound bodies require knowing the center mass of the mesh and since I have many merged meshes with different positions, it would be difficult. Is there a simpler way to join all meshes and keep their material? And also being able to set physics and gizmo.

Can you elaborate a bit?
Is it meant to be static? what impostor do you want to use? by gizmo do you mean each mesh must be individual and pickable? Can you provide a PG with what you want to achieve?

Yes. The connection should be static like a locked type of joint, it should be able to be dragged by gizmo all together. Each mesh should be individual and pickable. The meshes are not created in the app. They are merged as soon as I import the files. I will try to reproduce in a PG what I did in the case of merged meshes and send it here.

I created a PG here by copying and pasting some parts: Babylon.js Playground
You can download 2 glb files from:
The filename has 2 cubes with standard materials in it but no texture. It is importing well
The filename(1) has 2 cubes with texturing in one of them. It is not merging because of the material difference
Drag and drop these 2 files into the canvas to import it.

Meshes you want to merge must have the same attributes or you’ll see such message in the console:

Cannot merge vertex data that do not have the same set of attributes

For example, if you want to merge a cube that contains UV coordinates with a mesh that doesn’t have UV, it will fail.
Make sure both mesh have same set of attributes and it should work.

This could be a big limitation to my app. Actually, I’m able to import from blender and merge with different UV textures, etc maybe because when I export everything seems to be baked. The App is supposed to export the objects with different set of attributes and when I import again I would be able to manage them again in the same way. When I export they are already well merged, The problem is when I import again I need to merge it again. Or maybe I need to grab only the previous merged parent nodes? Maybe I am making a mistake to merge again something already merged in the first place. Sorry if I sounded confusing, hehe


how to take this objmeshes node and apply physics and gizmo? In that way, I don’t need to merge

You can load a scene, and for each mesh, depending on its name, create the physics impostor. Check this thread: