# Creating physics for an object (gltf)

**URL:** <https://forum.babylonjs.com/t/creating-physics-for-an-object-gltf/19540>\
**Category:** Questions\
**Created:** [March 29, 2021, 2:07pm UTC](https://forum.babylonjs.com/t/creating-physics-for-an-object-gltf/19540 "2021-03-29T14:07:47Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![Sesh1339](https://avatars.discourse-cdn.com/v4/letter/s/c77e96/32.png) [@Sesh1339](https://forum.babylonjs.com/u/Sesh1339)\
**Post date:** [March 29, 2021, 2:07pm UTC](https://forum.babylonjs.com/t/creating-physics-for-an-object-gltf/19540/1 "2021-03-29T14:07:47Z")

</div>

I faced the problem of creating the physics of objects, I realized that in order to determine collisions, it is necessary to create the physics of the object itself, in most of the examples that I looked at, special libraries were highlighted, oimo.js and cannon.js, it was told about the simplest shapes - spheres and boxes … But not a word about complex objects such as gltf, I tried instead of the words sphere and box - in the setPhysicsState ((BABYLON.PhysicsEngine. … Imposter, {mass: 4}) method, substitute the word Mesh, but nothing worked, besides I don’t understand how to apply physics to the imported object in functions -  
BABYLON.SceneLoader.ImportMesh (“”, “./”, “rinoseronte.gltf”, scene, function (Meshes, particleSystems, skeletons) {  
Meshes [0] .position.x = 0  
Meshes [0] .position.z = 25  
Meshes [0] .position.y = 5  
Meshes [0] .setPhysicsState (BABYLON.PhysicsEngine.MeshImposter, {mass: 4})  
// Meshes [0] .checkCollisions = true  
Meshes [0] .rotation = new BABYLON.Vector3 (0, -Math.PI / 2, 0)  
for (var i = 1; i \<Meshes.length; i ++) {  
if (Meshes [i] .animations.length! = 0) {  
scene.beginAnimation (Meshes [i], 0, 0, true, 1.0)  
}  
}  
Help me. you are welcome  
thanks

> **[@RaananW](https://forum.babylonjs.com/u/raananw)**
>
> Developer by day, developer by night. Part of @babylonjs’s core team. Opinions are mine. Sometimes I don’t have one.

---

<div class="post-metadata">

**Author:** ![Deltakosh](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/deltakosh/32/26635_2.png) [@Deltakosh](https://forum.babylonjs.com/u/Deltakosh)\
**Post date:** [March 29, 2021, 5:33pm UTC](https://forum.babylonjs.com/t/creating-physics-for-an-object-gltf/19540/2 "2021-03-29T17:33:02Z")

</div>

Adding @RaananW

---

<div class="post-metadata">

**Author:** ![Sesh1339](https://avatars.discourse-cdn.com/v4/letter/s/c77e96/32.png) [@Sesh1339](https://forum.babylonjs.com/u/Sesh1339)\
**Post date:** [March 29, 2021, 6:18pm UTC](https://forum.babylonjs.com/t/creating-physics-for-an-object-gltf/19540/3 "2021-03-29T18:18:16Z")

</div>

should I add it to the topic?

---

<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:** [March 29, 2021, 7:18pm UTC](https://forum.babylonjs.com/t/creating-physics-for-an-object-gltf/19540/4 "2021-03-29T19:18:37Z")

</div>

First of all, do you need to check only collisions ot you need more complex physics?

---

<div class="post-metadata">

**Author:** ![kvasss](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/kvasss/32/3774_2.png) [@kvasss](https://forum.babylonjs.com/u/kvasss)\
**Post date:** [March 29, 2021, 7:26pm UTC](https://forum.babylonjs.com/t/creating-physics-for-an-object-gltf/19540/5 "2021-03-29T19:26:15Z")

</div>

Hi. You can use complex meshes with Ammo.js. Look at this playground from line 689.  
[https://www.babylonjs-playground.com/#5MJ1X9#13](https://www.babylonjs-playground.com/#5MJ1X9#13)  
And read docs, my russian friend))

> **[Using A Physics Engine | Babylon.js Documentation](https://doc.babylonjs.com/divingDeeper/physics/usingPhysicsEngine)**
>
> Learn how to use one of the available physics engines in Babylon.js.

But be aware, you need simplified version of your mesh because meshImpostor has poor performance. For skeleton I think you need something like capsule as parent of your mesh.

---

<div class="post-metadata">

**Author:** ![Sesh1339](https://avatars.discourse-cdn.com/v4/letter/s/c77e96/32.png) [@Sesh1339](https://forum.babylonjs.com/u/Sesh1339)\
**Post date:** [March 29, 2021, 8:10pm UTC](https://forum.babylonjs.com/t/creating-physics-for-an-object-gltf/19540/6 "2021-03-29T20:10:40Z")

</div>

well, it would not be bad, probably first to study physics and, starting from know physics, already go on to collisions)

---

<div class="post-metadata">

**Author:** ![Sesh1339](https://avatars.discourse-cdn.com/v4/letter/s/c77e96/32.png) [@Sesh1339](https://forum.babylonjs.com/u/Sesh1339)\
**Post date:** [March 29, 2021, 8:16pm UTC](https://forum.babylonjs.com/t/creating-physics-for-an-object-gltf/19540/7 "2021-03-29T20:16:45Z")

</div>

Hi, I read this article, well, as I read it, I rather skimmed over it with my eyes, it seemed to me that very little has been said about Ammo, not in detail … Or, as I understand it, it is better to look for information not here, but on the official website of Ammo? Hmmm, if you advise Ammo, then I can be sure that she will reveal to me all about the physics of objects in Babylon? I understood you correctly?)  
And I read the dock a lot, I just ran into an incomprehensible moment, on which there is very little information, and if they write about the physics of objects, then on the forums, to which I have almost no access, so I turned here)

---

<div class="post-metadata">

**Author:** ![Sesh1339](https://avatars.discourse-cdn.com/v4/letter/s/c77e96/32.png) [@Sesh1339](https://forum.babylonjs.com/u/Sesh1339)\
**Post date:** [March 29, 2021, 8:21pm UTC](https://forum.babylonjs.com/t/creating-physics-for-an-object-gltf/19540/8 "2021-03-29T20:21:06Z")

</div>

By the way, I beg your pardon for spreading. Do you already have experience with collision physics, etc.? Can I show you some parts of the code where you use Ammo? To at least understand the structure of how and when to use this Ammo. I’ll be very thankful)

---

<div class="post-metadata">

**Author:** ![kvasss](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/kvasss/32/3774_2.png) [@kvasss](https://forum.babylonjs.com/u/kvasss)\
**Post date:** [March 30, 2021, 7:04am UTC](https://forum.babylonjs.com/t/creating-physics-for-an-object-gltf/19540/9 "2021-03-30T07:04:57Z")

</div>

Best way to get help with engine - create playground on [https://playground.babylonjs.com/](https://playground.babylonjs.com/)  
And you can write me private message with you contacts and we will be able to communicate in Russian. rather funny when two Russian speakers communicate in English

---

<div class="post-metadata">

**Author:** ![RaananW](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/raananw/32/28955_2.png) [@RaananW](https://forum.babylonjs.com/u/RaananW)\
**Post date:** [April 1, 2021, 1:55pm UTC](https://forum.babylonjs.com/t/creating-physics-for-an-object-gltf/19540/10 "2021-04-01T13:55:36Z")

</div>

seems to me like you are in very good hands 🙂  
if anything is not answered, let us know!
