# .attachToBone() Orientation Issues

**URL:** <https://forum.babylonjs.com/t/attachtobone-orientation-issues/11029>\
**Category:** Questions\
**Created:** [May 21, 2020, 4:42am UTC](https://forum.babylonjs.com/t/attachtobone-orientation-issues/11029 "2020-05-21T04:42:08Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![erey](https://avatars.discourse-cdn.com/v4/letter/e/f04885/32.png) [@erey](https://forum.babylonjs.com/u/erey)\
**Post date:** [May 21, 2020, 4:42am UTC](https://forum.babylonjs.com/t/attachtobone-orientation-issues/11029/1 "2020-05-21T04:42:08Z")

</div>

This is my blender setup:

 ![99299848_665921557535007_6679344722818891776_n](https://us1.discourse-cdn.com/flex024/uploads/babylonjs/original/2X/1/115189fed86ea3d870f56e6258fa3b245d1882fe.jpeg)

I export the FPS mesh and the center cube as two seperate glb files.

The center cube acts as a gimbal with movement animations (etc start move, stop move, jump), the FPS mesh has action animations (etc reload, shoot, draw). My idea is to parent the FPS mesh to the cube so that I can mix and match animations.

The orientation of each object is correct when I import them into babylon, but why does my FPS mesh end up mirrored when I parent it to the single bone in the cube using .attachToBone()?

 ![mirrored](https://us1.discourse-cdn.com/flex024/uploads/babylonjs/original/2X/a/a433467eec1ad8ed4f7d4ef3851a9880499c171b.png)

---

<div class="post-metadata">

**Author:** ![gbz](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/gbz/32/23780_2.png) [@gbz](https://forum.babylonjs.com/u/gbz)\
**Post date:** [May 21, 2020, 7:49am UTC](https://forum.babylonjs.com/t/attachtobone-orientation-issues/11029/2 "2020-05-21T07:49:08Z")

</div>

I wonder if this is related to the post [ArcRotateCamera's Radius affects the Rotation/Position of attachToBone Meshes](https://forum.babylonjs.com/t/arcrotatecameras-radius-affects-the-rotation-position-of-attachtobone-meshes/10524/10) solved by @Evgeni_Popov.

@erey, which version of Babylon.js are you on?

---

<div class="post-metadata">

**Author:** ![erey](https://avatars.discourse-cdn.com/v4/letter/e/f04885/32.png) [@erey](https://forum.babylonjs.com/u/erey)\
**Post date:** [May 21, 2020, 11:56pm UTC](https://forum.babylonjs.com/t/attachtobone-orientation-issues/11029/3 "2020-05-21T23:56:04Z")

</div>

I’m using to latest version, referencing [https://cdn.babylonjs.com/babylon.js](https://cdn.babylonjs.com/babylon.js) in my source.

I think this issue has something to do with the orientation of the cube bone. When a mesh is being attached to the bone and the bone is in an orientation different than whatever babylon.js interprets as the default orientation, that transformation difference is then also applied to the mesh object.

For example if I switch the cube bone direction in blender (remapping all constraints and animations to still work the same way with the new bone orientation)

 ![switch](https://us1.discourse-cdn.com/flex024/uploads/babylonjs/original/2X/a/a0c9a8af956a18c6ad07371d34ee1000e1bebb0f.png)

The FPS mesh and cube are imported individually correctly into babylon, but attaching the mesh to the cube results in this:

 ![ww](https://us1.discourse-cdn.com/flex024/uploads/babylonjs/original/2X/2/256d23438d1f744a31b9cadd72c6a13f29a09f51.png)

So I think I have to fix the bone orientation in Blender by mirroring it or if there is some way of “baking” the bone orientation in babylon.

---

<div class="post-metadata">

**Author:** ![gbz](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/gbz/32/23780_2.png) [@gbz](https://forum.babylonjs.com/u/gbz)\
**Post date:** [May 22, 2020, 3:48am UTC](https://forum.babylonjs.com/t/attachtobone-orientation-issues/11029/4 "2020-05-22T03:48:43Z")

</div>

@erey, as a test, could you try to use [https://preview.babylonjs.com/babylon.js](https://preview.babylonjs.com/babylon.js) instead of [https://cdn.babylonjs.com/babylon.js](https://cdn.babylonjs.com/babylon.js)?

---

<div class="post-metadata">

**Author:** ![erey](https://avatars.discourse-cdn.com/v4/letter/e/f04885/32.png) [@erey](https://forum.babylonjs.com/u/erey)\
**Post date:** [May 22, 2020, 4:50am UTC](https://forum.babylonjs.com/t/attachtobone-orientation-issues/11029/5 "2020-05-22T04:50:31Z")

</div>

The issue still exists with that version.

Ok so here is what I’ve explored: The cube bone has local axes xyz, when mesh is attached to the bone, the mesh is orientated such that it’s local axes match with the bone’s axes. Since the bone’s axes are flipped, the mesh also ends up flipped.

This means the issue lies in the original blender model or the glb importer.

I’ve tried correcting the bone’s axes in Blender, and while rotation and location changes in Blender are reflected in babylon, reflections are not. No matter how I reflect the bone in Blender, it still ends up in babylon with the same incorrect xyz axis relationship (But in a different rotation).

---

<div class="post-metadata">

**Author:** ![gbz](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/gbz/32/23780_2.png) [@gbz](https://forum.babylonjs.com/u/gbz)\
**Post date:** [May 22, 2020, 6:22am UTC](https://forum.babylonjs.com/t/attachtobone-orientation-issues/11029/6 "2020-05-22T06:22:53Z")

</div>

@erey, if you share the Blender files, we can help look into this further

---

<div class="post-metadata">

**Author:** ![sebavan](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/sebavan/32/57_2.png) [@sebavan](https://forum.babylonjs.com/u/sebavan)\
**Post date:** [May 22, 2020, 12:31pm UTC](https://forum.babylonjs.com/t/attachtobone-orientation-issues/11029/7 "2020-05-22T12:31:53Z")

</div>

Adding @bghgary in case he is aware of export issues on the blender glb front ?

---

<div class="post-metadata">

**Author:** ![erey](https://avatars.discourse-cdn.com/v4/letter/e/f04885/32.png) [@erey](https://forum.babylonjs.com/u/erey)\
**Post date:** [May 23, 2020, 1:08am UTC](https://forum.babylonjs.com/t/attachtobone-orientation-issues/11029/8 "2020-05-23T01:08:58Z")

</div>

[erey.zip](https://forum.babylonjs.com/uploads/short-url/dIZSbeXyAbX4yGU5VtxhffkNH6y.zip) (96.7 KB)

Here’s the blender file along with a simple code demonstration of the issue from line 83 to 92.
