# Physics, GLTFs, Instancing, and Parenting

**URL:** <https://forum.babylonjs.com/t/physics-gltfs-instancing-and-parenting/21369>\
**Category:** Questions\
**Created:** [June 3, 2021, 4:38am UTC](https://forum.babylonjs.com/t/physics-gltfs-instancing-and-parenting/21369 "2021-06-03T04:38:12Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![davehill00](https://avatars.discourse-cdn.com/v4/letter/d/ce73a5/32.png) [@davehill00](https://forum.babylonjs.com/u/davehill00)\
**Post date:** [June 3, 2021, 4:38am UTC](https://forum.babylonjs.com/t/physics-gltfs-instancing-and-parenting/21369/1 "2021-06-03T04:38:12Z")

</div>

I have a scene where I’m loading a GLTF object and creating a bunch of instances and then attaching physics impostors to each instance.

This kind of works, but I’m bumping up against a couple of strange behaviors (bugs?) that seem to be fighting against each other.

1. In order to get instanced rendering to work properly, I have to parent the instances of the glTF mesh to the parent of the mesh (i.e., to the \_root node) as described as the second option in the “Instancing a glTF object” on this page ([Instances | Babylon.js Documentation](https://doc.babylonjs.com/divingDeeper/mesh/copies/instances)). If, instead, I try mesh.setParent(null) before creating the instances, I end up in a situation where instanced rendering doesn’t work. i.e., the sign of the determinant of the instance mesh matrix doesn’t match the sign of the determinant of the original mesh (inside InstancedMesh::\_activate), and so each instance is rendered as a “regular” mesh.
2. Because I have to keep the parent of the mesh (as described in point #1), the PhysicsImpostor system warns me that “A physics impostor has been created for an object which has a parent”. This happens despite the fact that I’ve set “ignoreParent: true” in the PhysicsImpostor options parameter.

Is it a bug that PhysicsImpostor constructor isn’t checking “ignoreParent” before warning about parented object?

Am I doing something wrong to cause the “mesh.setParent(null)” version of glTF instancing to not work properly?

Thanks in advance!  
-dh

---

<div class="post-metadata">

**Author:** ![Evgeni\_Popov](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/evgeni_popov/32/4432_2.png) [@Evgeni\_Popov](https://forum.babylonjs.com/u/Evgeni_Popov)\
**Post date:** [June 3, 2021, 8:48am UTC](https://forum.babylonjs.com/t/physics-gltfs-instancing-and-parenting/21369/2 "2021-06-03T08:48:09Z")

</div>

Welcome aboard!

For 1, you can set `scene.useRightHandedSystem = true` to avoid having a transformation on the first node of the hierarchy (in that case, the transformation will be the identity). Thay way, you can remove the parent of the meshes altogether (first option in the doc you linked). If I understand it well, that should also fix 2 but @Cedric will know more about this one.

---

<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:** [June 3, 2021, 8:59am UTC](https://forum.babylonjs.com/t/physics-gltfs-instancing-and-parenting/21369/3 "2021-06-03T08:59:47Z")

</div>

I think @Evgeni_Popov is right.  
`ignoreParent` is not used for the warning. Can you share a PG? Physics and hierarchy is a complex beast.

---

<div class="post-metadata">

**Author:** ![davehill00](https://avatars.discourse-cdn.com/v4/letter/d/ce73a5/32.png) [@davehill00](https://forum.babylonjs.com/u/davehill00)\
**Post date:** [June 4, 2021, 2:52am UTC](https://forum.babylonjs.com/t/physics-gltfs-instancing-and-parenting/21369/4 "2021-06-04T02:52:38Z")

</div>

> [@Evgeni\_Popov](#):
>
> scene.useRightHandedSystem

Awesome, thanks! That worked. 🙂

---

<div class="post-metadata">

**Author:** ![davehill00](https://avatars.discourse-cdn.com/v4/letter/d/ce73a5/32.png) [@davehill00](https://forum.babylonjs.com/u/davehill00)\
**Post date:** [June 4, 2021, 3:04am UTC](https://forum.babylonjs.com/t/physics-gltfs-instancing-and-parenting/21369/5 "2021-06-04T03:04:20Z")

</div>

Here’s a playground – if you look in the console, you’ll see the warning.

[https://playground.babylonjs.com/#WGZLGJ#3078](https://playground.babylonjs.com/#WGZLGJ#3078)
