- Home /
Import .fbx - Newly added mesh vertices in newly added Vertex Group (for new bone in already existing armature) all being translated into root bone position in Skinned Mesh Renderer
My problem is as follows:
I have a .blend file with already existing character geometry. All fine, I rigged it, I animated it - it imports as .fbx to Unity just fine - all the animation clips are present and animating properly (I don't use .blend file directly due to some issues with newly added bone to already existing and animated armature, which I'm currently going to describe).
My problem starts when I have a model parented to that already animated armature and add just new bone and new geometry that will be attached to it. That new geometry is simply a plane in this case. It shows in Blender just fine, also after reimporting it with .fbx. But, in the Unity, when I render my mesh with use of Skinned Mesh Renderer, all newly added vertices of that new geometry (that plane) are being translated to the position of Root Bone set by that renderer. The already existing geometry that was present in the model before renders fine. When I remove these new vertices from their Vertex Group (which I added manually in Blender to weights group after adding that bone to already existing and animated armature, giving it that bone's name, it animates fine in Blender) - simply unassigning them - mesh renders fine with that Unity renderer, but of course I have no deformation applied to that part of geometry, which is not what I'm going to achieve.
The reason why I don't use .blend file directly anymore is because of that new bone's adding process indeed - I must have broken something with the overall animation structure of that model that is being handled internally by Unity - it results in that when I import it into the engine, the mesh is partially animated (not all the geometry has the deformation applied) and not all of the animation clips are recognized and imported (or there are no clips at all, just the Default Take) - so that's the matter for another topic which I don't bother to touch.
I'll just add that problem concerns only newly added Vertex Group - when I add these vertices to one of already present ones, it renders fine (but of course I can't apply desired deformations then, that's why I need new weights group)
Answer by Spinu2b · Jan 21, 2018 at 05:40 PM
Solution - make a backup of a .blend file with old animation clips data, clear animation data of armature, remove all animation clips completely from the scene, recreate them from scratch in Action Editor and copy all the keyframe poses frame-by-frame from backup file to respective newly created animation clips.
You have to do it every time you modify the rig.
Workaround - make this new geometry a separate object and place in Hierarchy as a child of one of bones (works if your animation characteristic is simple enough)
Answer by Pinkuboxu · Jan 21, 2018 at 06:33 PM
Forgive me but I'm having trouble knowing exactly what your work flow is. It kind of sounds like you are trying to add geometry to the models and reusing your prefabs. Also, .blend files are just the same as .FBX files that you export. Unity simply uses a python script and opens blender then uses the same exporter you use to make an .FBX file. I'll go over everything I've done over the past few months to fix similar problems that I have had.
You need to make sure you rig your model completely before using it in Unity. In fact, general workflow is to let your artist model, rig, and texture your assets before you even start using them. You use simplified prototype/programmer art to fill in for the time being. I had to learn this too as I'm basically artist and programmer, I use a simple shape to stand in for my characters and complete my assets before using them. IF you fully rig your character you should be able to animate later and even during development but you have to be sure to finish the rig before you start animating it or using it in Unity. You'll run into many problems otherwise. In short Adding new parts to already existing model files in blender causes headaches. Don't do it.
If you have missing animations, as in the importer doesn't show them or they aren't showing up in the mesh asset in the project window, then make sure in blender that all animations have actions tied to them, and make sure each action has a fake user in blender. You may also have to delete the original mesh and save a new version from blender for things to show up right.
If you are noticing that certain bones are not animating and you are using the humanoid type set up, you may have bones that the animator donsen't recognize as humanoid. You need to get to the configure scene the model in the import inspector to see which bones are not working properly. You can get non humanoid bones to animate by giving the model a mask and including the bones you need to animate. I hope that helps.
So, in this situation, do you think that creating new armature (just copy of the old one, without weights or anything, with new extra bones added) on new model instance (copy of old mesh without armature, new file, anything) and then copying keyframes one-by-one from old clips to new ones would work (with the same names as old clips)? I don't find recreating all animations by hand really comfortable. If it is going to work I would be very pleased, so I can then add new weights group to those new bones before copying old animations to new clips. So in the future I could even somehow automatize that whole process (some Python script), just in case I did such kind of blunder again (read mesh vertices weight data for respective bones from already existing Vertex Groups, place a new mesh without armature, build new armature from scratch, name the bones, position, scale and rotate them properly, apply modifiers (so far I only use Inverse $$anonymous$$inematics, for my own needs it is enough) create animation clips with proper names, copy all the keyframes from old clips to new clips and we would be done :) ). It would be interesting to do such a thing for me.
That would allow some idempotent manner in development - I mean we always start from the same state and avoid some headaches when we run into trouble messing up with files. But yes, proper workflow should be taken into account in the first place, thank you for advice.
If you have everything working in Blender then it should be fine and you shouldn't have to redo any animations, as long as they work in Blender. Don't delete the original .blend but delete the .FBX that you are trying to use in Unity as well as the prefab that will be your actual game object in the scene, then re-export from blender and see if things work right after setting up your prefab again. Usually, if your bones are named properly Unity will take care of the rest, if you are working with human models and the humanoid type animator.
What extra bones are you adding? You probably don't need to add any bones unless they are a part of the body of the character, which should all be there before you start attaching things. @Spinu2b's suggestion will work in getting something like a sword or shield to attach to a hand, if you place it under the hand bone's transform as a child in the Armature object in the hierarchy view of the characters prefab. You'll just have to make sure to create a separate model and prefab for your object, and have it's rotation correct so it points right. That way you don't have to worry about weights at all unless you need them to deform with the characters rig like for Clothing, which usually isn't as simple and I find that using the armature for equipment slots gets messy after a while if your rig is complicated enough.
I had a hell of a time trying to get Blender and Unity to work well together and I never really had anyone explain it to me. I just had to grok my way through until I found a workflow that worked for me.
I did remove the whole prefab and it didn't change my situation. Still same issues.
The issue is that I'm using generic type of animator (I wasn't aware of humanoid type of rig, I wasn't following any standards when doing it, I named my bones my way and did generally the whole rig in a custom way, not setting anything additional).
And I have differences when doing export directly via Blender myself, and when using Unity (maybe some parameters in the export script are set differently by the engine?). I have couple of possible solutions in this case, I'll give a Python script a try and see if it works (if it doesn't, then I'll go deeper to investigate the reason, learning it hard-way). If it's going to work, I'll share this script so others could benefit from it.
Problem persists when I import my models to completely different project, so it has nothing to do with scene/project metadata.
Your answer
Follow this Question
Related Questions
Blender stops exporting after certain animation 0 Answers
Is skinning weight dependent on animations or on base model? 0 Answers
model isnt animating in 3rd person 1 Answer
Why do I have jittering or extraneous movements in my animation after importing from Blender? 1 Answer
Cutscenes from video 1 Answer