Exporting Animation

Hi,
Im having trouble when exporting using the Unity Babylonjs plugin.
If I have a model that has an Animator component attached,(for example an Idle animation on a character) I can see that the animation is working after export, however this object becomes rotated, I think 180 degrees. Is this a know issue, or am I missing a specific setting. Is there something I can do as a fix for this?

Hello and welcome!
Pinging @MackeyK24 who is the mastermind behind the unity exporter

Well this could be a couple things… dont know the Translation setup of the component mesh.

But normally if you character is facing down Z-Axis then your character is probably facing AWAY from the camera. To make that character face the camera, you would set Y rotation to 180. But the animation is still facing forward (local)…

Anyways In Unity to cope with this you Normal DONT put your model object as the main object that you rotate… Create a parent empty Game Object for your character… Which is really what you should be doing in the first place. This top level empty game object is where you actually attach all the components that give it functionality… INCLUDING the animator component… that way you can even prefab that empty object as a base character setup with all the animation state setup… and simple drop ANY humanoid character rig model as a child of that facing FORWARD with NO ROTATION and NO ANIMATOR… that is mesh is just along for the ride… purely visual… The animator control on the top level parent game object will look down into its children and bake all animations onto each skinned mesh renderer’s bones… Giving you that Unity Mechanim style animation RETARGETING system for babylon :slight_smile:

3 Likes

That paragraph was helpful to me. Thanks.

That was a very thorough answer, thank-you. But I’m not sure but you may have misunderstood my badly worded rambling.
The issue is that everything works fine in Unity. It only flips 180 degrees when I export via BabylonJS and preview in the browser.

I do exactly what you say regarding putting components on a parent.

Hope you have some more ideas!

Mark

Hmm… Dunno… If you send me the scene… i will check it out to see if i can tell what is going on :slight_smile:

That would be huge… But I can make a small scene with the offending object/animation.
Did you want Babylon installed already, would add to file size…

That kool small scene… no need Babylon Toolkit included… I will try test with current and upcoming toolkits

How is it that so many few understand the coordinate system they work in? Many applications use a z axis up while others use a y axis up. And then there are right coordinate systems and left coordinate systems. The magnetic earth is a z axis up system. But that’s not what many applications use. Just change you’re coordinate system.

Galen

2 Likes

@Galen I fail to see what that’s got to do with my problem, the issue is the difference between the project in Unity and how the animation component affects the babylon export tool. Nothing else.

@MackeyK24 sorry for delay on scene, not sure how to send it to you… zipped and probably DM you a WeTransfer…

Dropbox it or something… or upload somewhere and send me url

Yo @markfrancombe … I sent you message detailing the problems i had with your scene.

Just send me models and animations (.fbx) files…

Jus drag that to Babylon Sandbox

I dug out Liam V2.fbx… Drop it on the new Toolkit with the default YBot Animations and everything looks great… The model moves as expected. Here is Test GLB… of your V2 Liam with my YBot Animation Controller:

LiamTester.glb.zip (557.4 KB)

It must be your Parent/Child Setup or the animations themselves are KEYFRAMED with that rotation in them… Dunno I will have to take a look at the animations (.fbx)

Note: Liam Does Need RE-SKINNING as well

Thanks for the test, I can see that it works perfectly in Babylon Sandbox. So im sure I will find a combination fo controller and animation clip thats gonna work. Didnt fully understand your message. Did you expect me to send you the fbx and animations I used, or did you mean that you had solved it, that it must be the animation clips?

The thing about it being too complex a character. Sure, the prefab you got was a typical Unity set-up, with variations (hair / clothes /shoes) this is a test from my 3D designer. We are making a Health and Safety game, and this part is where the user should choose what safety equipment is needed for specific jobs. SO the final thing will have a character, in underwear, and you “dress” them for specific jobs. It kind of has to be like that. I reality, he doesnt even HAVE to animate… but I want him to. But the totally scene will contain NOTHING else. So getting the simple, no addition bits; charcter working, is my first priority, childing extras that can be enabled and disabled will come next.

So my forst question still stands really, if it works in Unity, why doesnt it work in Babylon. Im not saying it should, Im asking “what do I need to do to get the same effect”.

But you seem to be saying that the fault lies in the animations and that they have some kind of keyframed rotation built in. Ill check that, but still done see why they work in Unity and not afyer exprot.

Ill go back to basics and animate a cube…

Thanks for you help up to now, Ill try to figure some stuff out an get back to you if I have some more detailed questions…

Mark

Well its partly the current exporter. The GLB i made using the new toolkit.

As for the animations… This has been an issue with the Unity Exporter (the way we make the local bone bind pose matrix and the way I BAKE animations to those bones).

Somehow (I dont know how, Unity compensates for that 90 degree rotation that is on the X-Axis of your animations)… Now when I BAKE animations… I take those POSITIONS, ROTATIONS and SCALE from that animation and BAKE that as BABYLON Animations Key Values. So its a what you see is what you get… If you take a Idle animation from mixamo and look at the KEYFRAMES… there is NO 90% rotation on those animations (and your character works fine… even with al the pieces… Although you need to RESKIN those pieces to have clean bones that Babylon will use)

Remember… we are EXPORTING what we can for use in babylon. Then my scene manager RE-CONSTRUCTS that unity scene as best it can using the metadata… Unity has a whole NATIVE ANIMATION SYSTEM… I can just Sample a bone TRS at a givin frame time against a bone transform, then record the local position, rotation and scale as babylon animation keys… There is no telling what logic Unity has to use those native animations. I cannot… So the Skin Job on the model has to BE CLEAN and Animations need to CLEAN as well (No funky rotations or scaling)

What all that being said… You can Always compensate for the 90 degree rotation. Simple create a empty game object in between your root game object and the model and put the inverse rotation on that game object.

– Player Object (with all the components)
— Pivot Object (-90 X-Axis)
— Your Actual Model that gets animated and turn 90 degrees

Now when you model is just in the scene it will be turned -90 degrees… But when the animations are attached and running the original 90 degrees from the animation will flip the guy back the way you want him to face.

Try that :slight_smile:

Or use better cleaner animations :slight_smile:

1 Like

Yo @markfrancombe … Shit dude… I forgot to to tell you about the “Animation Window” under tools in Unity… This Window lets you play the RAW animations… This is the same RAW animation key frame values i record when baking the animations. It does not FIX your problem. But it will allow you to see exactly what Babylon will look like when animating (With clean skins).

If you look at your character in the scene and play the idle animation in the Animation Window you will see you whole character rotate to a different position… If you look at the Game Window you also notice that the character has rotated OUT of camera view. This is exactly what happens in Babylon. That window is playing the raw animations on the character in design time. I dont know what unity is doing when it actually runs a native unity game. But you can use that Animation Window to see the raw stuff that actually gets exported. Then if you still gotta use those animation… Use an intermediate game object to compensate for that rotation… Hope that help bro… Sorry… but not finished the new exporter yet :frowning:

I can easily just dump any Animator stuff. Im totally used to the animation window thats the old legacy way of doing shit anyway. Chances are I just need idle animations anyhow.
Thanks for your detailed instructions, as you can probably tell Im not the programmer on the project, but completely understood all you said. We were screwed by the customer suddenly coming up with “and we want it running in a browser” when we were planning an app… so we all got thrown into Babylon pretty quick… loving it so far…

M

Related question.
When I export a simple scene with character in an idle animation from Unity, I don’t how/where the animation ends up. How do I play the idle animation? I do see the skeleton… just not how to start up the animation?? Is there some trick with that SceneManager object?

I did discover an alternate way to export animations from Mixamo (which I was trying to do via Unity previously), for anyone who comes across this thread. This video was helpful: YouTube

Essentially, export as FBX and then use this converter to GLB: Convert 3D models to GLTF | BlackThread.io

Next up for me is to try combining animations using Blender: YouTube … although have not had luck exporting animations to GLB from Blender.

1 Like