Hello guys, I have recently got some models and created some animations for my game, but I have ran into one issue fairly quickly - when I am attaching mesh to the bone, it is misplaced (and I mean misplaced compared to the bone position in Blender).
In Blender my “swordBone” is in right hand, but it appears to be in left hand when imported into application. It is something I can live with, but it will be better when it could be fixed somehow
Well looking at your 2 images, I see the bone you want to add the "sword" to, and I see where the “sword” ends up. So I will add my immediate thoughts.
The "sword’ seems to be added to the left side but not to the hand. It ends up near the top of the glove.
I am intrigued by the position that the “sword” mesh has before it is attached. Is it binding to the wrong bone? Or is there an issue with the origin and rotation of the sword before it binds to the hand bone?
Here is an example that I did a longtime ago updated just to use Babylon Js 4.1xx
Click on the “sword” to bind to the skeleton. Click the sword again to unbind it.
Now click the T-shirt to animate the hand with and without the “sword”
Note the position of the unbound “sword” - the origin is 0,0,0 (between the legs). There is a slight rotation which accounts for the slight angle of the hand
As @Deltakosh suggests, more info would help - eg: the blend file
Hello, that small misplacement - weapon appears higher than it should was caused by transforms in Blender, that was not applied. I have applied all transforms and then sword appears where the swordBone is - but on the other hand.
Interesting is, that it works ok when I export into Babylon file, but it switch hands when exported into gltf. I will create playground with it ASAP:
But I am unable to link it from the plyground because cross-origin browser policy :-/ is there some other way how to use my gltf file in playground to reproduce that problem ?
The coordinate system is right-handed in gltf files and left-handed in Babylon: maybe you can try to set the scene as right handed and see what happens (scene.useRightHandedSystem(true))?
There was once a discussion about having a flag to convert the right-handed to left-handed coordinates when loading a gltf file, but I don’t know if it were ever implemented.
Sword is now correctly in right hand … but whole scene is flipped and models walking backwards which is certainly funny
EDIT: I could tweak my scene to work with this “flipped” system, but problem is, that other models that are in babylon format (and not in GLTF) are then flipped too (because they were ok in the first place) It would be better if both formats use the same system
Hello guys I have found that problem. Somehow my source mesh (in gltf file) had Z scaling value = -1 and I have later changed it to +2 (positive value) which rotated whole mesh. When I respect the original value, then sword appears correctly. It is really weird because I am always applying all transformations in blender before I exporting files.