# How to attach physics to imported mesh?

**URL:** <https://forum.babylonjs.com/t/how-to-attach-physics-to-imported-mesh/5526>\
**Category:** Questions\
**Created:** [September 8, 2019, 9:58am UTC](https://forum.babylonjs.com/t/how-to-attach-physics-to-imported-mesh/5526 "2019-09-08T09:58:02Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![splash27](https://avatars.discourse-cdn.com/v4/letter/s/76d3ee/32.png) [@splash27](https://forum.babylonjs.com/u/splash27)\
**Post date:** [September 8, 2019, 9:58am UTC](https://forum.babylonjs.com/t/how-to-attach-physics-to-imported-mesh/5526/1 "2019-09-08T09:58:02Z")

</div>

I hope that this is not a bug, just I am doing something wrong:  
[https://www.babylonjs-playground.com/#EHGYRF](https://www.babylonjs-playground.com/#EHGYRF)

Created mesh works as expected. For imported mesh gravity works, but mesh goes through ground.

---

<div class="post-metadata">

**Author:** ![HappyDev](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/happydev/32/2236_2.png) [@HappyDev](https://forum.babylonjs.com/u/HappyDev)\
**Post date:** [September 8, 2019, 10:58am UTC](https://forum.babylonjs.com/t/how-to-attach-physics-to-imported-mesh/5526/3 "2019-09-08T10:58:11Z")

</div>

I think it has to do with the fact that your barrel mesh is composed of smaller meshes thus the impostor doesn’t apply correctly when you use it on the **root** node.

---

<div class="post-metadata">

**Author:** ![splash27](https://avatars.discourse-cdn.com/v4/letter/s/76d3ee/32.png) [@splash27](https://forum.babylonjs.com/u/splash27)\
**Post date:** [September 8, 2019, 11:39am UTC](https://forum.babylonjs.com/t/how-to-attach-physics-to-imported-mesh/5526/4 "2019-09-08T11:39:51Z")

</div>

Probably, but how to fix? Create bounding transparent cylinder? Sounds CPU/GPU expensive and not elegant.

---

<div class="post-metadata">

**Author:** ![HappyDev](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/happydev/32/2236_2.png) [@HappyDev](https://forum.babylonjs.com/u/HappyDev)\
**Post date:** [September 8, 2019, 11:41am UTC](https://forum.babylonjs.com/t/how-to-attach-physics-to-imported-mesh/5526/5 "2019-09-08T11:41:27Z")

</div>

For the current mesh probably merging the submeshes.

---

<div class="post-metadata">

**Author:** ![Givo](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/givo/32/4968_2.png) [@Givo](https://forum.babylonjs.com/u/Givo)\
**Post date:** [September 8, 2019, 3:59pm UTC](https://forum.babylonjs.com/t/how-to-attach-physics-to-imported-mesh/5526/6 "2019-09-08T15:59:50Z")

</div>

This is not a bug, but something odd about physics. Mesh impostors can only collide with spheres. I don’t know why.

Also, you don’t need the check collisions property if you are using a physics engine (like now). It is used for the camera’s built in physics.

Playground with sphere: [https://www.babylonjs-playground.com/#EHGYRF#2](https://www.babylonjs-playground.com/#EHGYRF#2)

It collides but it bugs out.

---

<div class="post-metadata">

**Author:** ![JohnK](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/johnk/32/26764_2.png) [@JohnK](https://forum.babylonjs.com/u/JohnK)\
**Post date:** [September 8, 2019, 4:35pm UTC](https://forum.babylonjs.com/t/how-to-attach-physics-to-imported-mesh/5526/7 "2019-09-08T16:35:29Z")

</div>

Changing the ground to a thin box works (planes are always a physics problem). The root has no dimensions so the dimensions for a impostor on the root are suspect.

One way is to place the barrel over the cylinder as parent [https://www.babylonjs-playground.com/#EHGYRF#3](https://www.babylonjs-playground.com/#EHGYRF#3)

Order of code is important.

---

<div class="post-metadata">

**Author:** ![splash27](https://avatars.discourse-cdn.com/v4/letter/s/76d3ee/32.png) [@splash27](https://forum.babylonjs.com/u/splash27)\
**Post date:** [September 10, 2019, 7:04pm UTC](https://forum.babylonjs.com/t/how-to-attach-physics-to-imported-mesh/5526/8 "2019-09-10T19:04:08Z")

</div>

Well, I fixed it in playground somehow, by changing plane to box (should not be very thin) and assigning BoxImpostor instead of CylinderImpostor: [https://www.babylonjs-playground.com/#EHGYRF#4](https://www.babylonjs-playground.com/#EHGYRF#4)

This worked for playground but not in my app. I didn’t find any suitable coding solution.

So then I just imported .glb file to Blender and saved a texture from there in a separate file.  
Then I created new Blender project with simple cylinder, edited UV map over texture that I saved before, removed camera and light (Blender adds them by default) and exported new barrel as .babylon file.  
Then I put .babylon file and texture file in one folder in my app. During import to app .babylon file shows only one mesh (my cylinder), so I added a physics to it as usual and everything has started to work.
