# Is Babylonjs currently supporting physics for parent or child meshes?

**URL:** <https://forum.babylonjs.com/t/is-babylonjs-currently-supporting-physics-for-parent-or-child-meshes/28956>\
**Category:** Questions\
**Created:** [April 1, 2022, 8:43am UTC](https://forum.babylonjs.com/t/is-babylonjs-currently-supporting-physics-for-parent-or-child-meshes/28956 "2022-04-01T08:43:47Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![mathus1](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/mathus1/32/8535_2.png) [@mathus1](https://forum.babylonjs.com/u/mathus1)\
**Post date:** [April 1, 2022, 8:43am UTC](https://forum.babylonjs.com/t/is-babylonjs-currently-supporting-physics-for-parent-or-child-meshes/28956/1 "2022-04-01T08:43:47Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![carolhmj](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/carolhmj/32/25918_2.png) [@carolhmj](https://forum.babylonjs.com/u/carolhmj)\
**Post date:** [April 1, 2022, 11:49am UTC](https://forum.babylonjs.com/t/is-babylonjs-currently-supporting-physics-for-parent-or-child-meshes/28956/2 "2022-04-01T11:49:41Z")

</div>

I think not, but let me check with @Cedric

---

<div class="post-metadata">

**Author:** ![Cedric](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/cedric/32/2742_2.png) [@Cedric](https://forum.babylonjs.com/u/Cedric)\
**Post date:** [April 1, 2022, 12:01pm UTC](https://forum.babylonjs.com/t/is-babylonjs-currently-supporting-physics-for-parent-or-child-meshes/28956/3 "2022-04-01T12:01:53Z")

</div>

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

> **[Compound Bodies | Babylon.js Documentation](https://doc.babylonjs.com/divingDeeper/physics/compoundBodies)**
>
> Learn all about physics compound bodies in Babylon.js.

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

> **[Joints | Babylon.js Documentation](https://doc.babylonjs.com/divingDeeper/physics/joints)**
>
> Learn all about using joints in physics engines within Babylon.js.

---

<div class="post-metadata">

**Author:** ![mathus1](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/mathus1/32/8535_2.png) [@mathus1](https://forum.babylonjs.com/u/mathus1)\
**Post date:** [April 1, 2022, 3:54pm UTC](https://forum.babylonjs.com/t/is-babylonjs-currently-supporting-physics-for-parent-or-child-meshes/28956/4 "2022-04-01T15:54:03Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Cedric](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/cedric/32/2742_2.png) [@Cedric](https://forum.babylonjs.com/u/Cedric)\
**Post date:** [April 1, 2022, 4:26pm UTC](https://forum.babylonjs.com/t/is-babylonjs-currently-supporting-physics-for-parent-or-child-meshes/28956/5 "2022-04-01T16:26:22Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![mathus1](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/mathus1/32/8535_2.png) [@mathus1](https://forum.babylonjs.com/u/mathus1)\
**Post date:** [April 1, 2022, 4:40pm UTC](https://forum.babylonjs.com/t/is-babylonjs-currently-supporting-physics-for-parent-or-child-meshes/28956/6 "2022-04-01T16:40:07Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![mathus1](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/mathus1/32/8535_2.png) [@mathus1](https://forum.babylonjs.com/u/mathus1)\
**Post date:** [April 2, 2022, 3:58am UTC](https://forum.babylonjs.com/t/is-babylonjs-currently-supporting-physics-for-parent-or-child-meshes/28956/7 "2022-04-02T03:58:36Z")

</div>

I created a PG here by copying and pasting some parts: [Babylon.js Playground](https://playground.babylonjs.com/#CS3DSS)  
You can download 2 glb files from: [https://github.com/mathus1/plataformaonline/tree/master](https://github.com/mathus1/plataformaonline/tree/master)  
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.

---

<div class="post-metadata">

**Author:** ![Cedric](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/cedric/32/2742_2.png) [@Cedric](https://forum.babylonjs.com/u/Cedric)\
**Post date:** [April 4, 2022, 2:09pm UTC](https://forum.babylonjs.com/t/is-babylonjs-currently-supporting-physics-for-parent-or-child-meshes/28956/8 "2022-04-04T14:09:45Z")

</div>

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

```auto
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.

---

<div class="post-metadata">

**Author:** ![mathus1](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/mathus1/32/8535_2.png) [@mathus1](https://forum.babylonjs.com/u/mathus1)\
**Post date:** [April 4, 2022, 2:56pm UTC](https://forum.babylonjs.com/t/is-babylonjs-currently-supporting-physics-for-parent-or-child-meshes/28956/9 "2022-04-04T14:56:21Z")

</div>

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

![image](https://us1.discourse-cdn.com/flex024/uploads/babylonjs/original/3X/a/f/af01b5e5ffbc004db4363384ec790446e93acfba.png)

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

---

<div class="post-metadata">

**Author:** ![Cedric](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/cedric/32/2742_2.png) [@Cedric](https://forum.babylonjs.com/u/Cedric)\
**Post date:** [April 5, 2022, 8:22am UTC](https://forum.babylonjs.com/t/is-babylonjs-currently-supporting-physics-for-parent-or-child-meshes/28956/11 "2022-04-05T08:22:17Z")

</div>

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

> [@Loading gltf and physics not working, what am I missing?](https://forum.babylonjs.com/t/loading-gltf-and-physics-not-working-what-am-i-missing/4878/2):
>
> Here is my 2 cents… I have been trying to tell folks for quite some time about GLTF meshes and Physics and PARENT containers. They are screwy… and in GLTF … everything has a parent … up to the root node. Anyways… You need a function like this: var createPhysicsImpostor = function(scene, entity, impostor, options, reparent) { if (entity == null) return; entity.checkCollisions = false; const parent = entity.parent; if (reparent === true) entity.parent = null; entity.physicsI…
