I’m experiencing a behaviour I can’t really understand with fbx imported from maya, here’s the whole thing :
I have a body with a rig, skinned and animated. (in an fbx)
I have a gauntlet with the exact same rig, skinned and with no animation. (in another fbx)
both have the option “optimize gameobject” checked on the rig import.
Now, when I take the skinned element from the gauntlet and I move it to the body object, it perfectly follow the animations of the body but when I add the gauntlet in play mode it’s not working ! The gauntlet is positioned at the “default” position it has and it moves but doesn’t follow the arm at all.
I’ve been searching what could I do to fix that and I found two weird things :
The transform value are moving a lot in the first case (when it works) but not at all when the object is added at runtime.
When I reset the controller (by setting it to null in the body “animator” component and then back to the “good” controller, by code or in the inspector) it solves the problem : the gauntlet follow the arm.
Although I kinda “solved” my problem with the second thing, I’m having hard time figuring out what’s happening here… So if someone knows, and have a better idea, I’d gladly take it !
Please tell me if I’m not clear, and what information are missing if any.
thanks !
Edit : In fact the gauntlet is working as soon as I edit any property of the animator… as it seems any changes reset the animator
This seems to be a similar issue others encountered before.
Search through @Mecanim-Dev posts - he was providing ‘why’ this similar issue was happening to other developers.
I’ve already looked a bit since I saw him answer almost similar questions, but he have a loooot of posts and I couldn’t find anything about precisely this. I’ll search a bit more though, thanks
Edit : Well nope, couldn’t find an answer, maybe i’m really bad at searching
Have you restarted Unity lately? I have definitely had issues with code that I swear should be working that just didn’t behave correctly. If that is the sort of situation you have then try a restart.
Do you get the same issue if you turn off optimization in the rig? Not that that’s a solution in any way, but it’s interesting data.
Also, try calling Animator.Rebind(). The docs say that “This function can be used when you manually change your GameObject hierarchy by script, like combining meshes or swap a complete transform hierarchy.”
If i turn off the optimization it’s even worse, when I try to add the gauntlet alone, there is just nothing appearing… I didn’t try to “reset” the animator without optimization though, but that would be the same problem.
Thanks for the “rebind” thing, I totally missed that, it works exactly the same as my way of “resetting” (which is logical) but that means it does also reset the animator’s state so I still have to “save” the state and restore it after adding the gauntlet (which is what I wanted to avoid).
Anyway I understand a bit better why it’s like that so thanks, I guess I just hoped that there would be a “rebind” function that keeps the animator’s state, but oh well it’s not that hard to do it myself !