Home Website Youtube GitHub

Rigging export to unity

Hello! I’m having a lot of trouble exporting to Unity.

In first place I’m using game tools. When I export, I have these bind unable to find bind pose and I’m thinking that this could cause the bad poses in unity. Here is a extract of the error, it’s a lot longer.

bindError

I looked up for a solution so I have to delete the bindPose and then run a Code to get again this bindPose but still have a similar Error. (I did this before Disconnect and export in game tools, it doesn’t let me after reference and connect)

bindError2

Thanks in advance!!

Hi @Diego_Moya

mGear’s uses the dagPose node node to store the default position of controls so that you can call the dagPose command on that node and go to your rig default position. Try deleting all dagPose nodes on the scene just to see what happen. I will try to find time to test this out.

Let me know
Cheers

1 Like

and then run a Code to get again this bindPose

It would help to actually see the code you ran when you ask for help like this.

This works for me when exporting to Unity:

# 1. Delete all the existing bindPoses. Make sure your rig is in neutral pose first!!!
# And ideally save a COPY of your scene first, because this is destructive.
import pymel.core as pm
pm.delete(pm.ls(type='dagPose'))

# 2. Use this line if you are selecting all your joints
allYourJoints = pm.selected()

# 2. OR use this line if you have all your joints under a single group.
# Select the group and run this.
allYourJoints = yourSkeletonGroup.getChildren(ad=True, type='joint')

# 3. The command that works for me to make a fresh bindPose.
oDag = pm.dagPose(allYourJoints, bp=True, save=True)
2 Likes

How are you using the dagPose in Unity? I’ve been exporting too and I’m curious about how other people are doing it, as I’m still researching the best way for us:

  • On one side, I’m exporting the skeleton, the mesh and the weights in a single FBX (after running some code to strip everything from the rig in a way that does not break).

  • On the other side, I’m baking all the joints transforms and exporting just the skeleton.

I’ve been able to load those clips in the first file without(ish) issues, using the Generic avatar as well as Humanoid (with a custom template, but works fine so far).

1 Like

I deleted the bindPose, then I ran your code, used gameTools to disconnect and export, but when I use reference and connect, this happens:

error1

I used allYourJoints = pm.selected()

Hope there is a solution

Could you give more details please?
What code are you running to strip everything from the rig in a way that does not break?

What do you mean by baking all the joints transforms? Why do you export only the skeleton?

Thank you very much!!

I’m not using the dagPose in Unity personally, so I can’t give you any special insights. I’m just working on a tool that bakes and exports our rigs somewhat automatically. And if I don’t rebuild the dagPose, the joints all come in sideways and skewed. If I do, they come in properly.

(Also, I’m not actually exporting mGear rigs. My Unity based project is a different rig. sacrilage! :grimacing:)

@Diego_Moya again, sorry I’m using a different rig, so I might not be able to help much. But did you try resetting the bindPose AFTER using the gameTools to disconnect? I think making a new bindPose should come as the last step before you export, after your skeleton is all ready to be exported.

1 Like

Our goal is to have one character (geometry + skeleton + weights) where we can load a bunch of different animations (skeleton with baked transforms). I’m not using the game exporter because we need some extra customization when exporting (we need to create a couple of root bones among other things). Also, by default mGear has the joints as ‘non-keyable’, so make sure to change that if you are exporting animated skeletons to your game engine.

Roughly, the steps I follow are these:
1/ if the rig is a reference, import it in the scene. Remove namespaces.
2/ create the additional joints I need in the joint hierarchy (this is particular for our case).
3/ set all the joints as keyable.
4/ bake all the joints’ animation. You can use something like this:

 min = mc.playbackOptions (q = 1, minTime = 1)
 max = mc.playbackOptions (q = 1, maxTime = 1)
 mc.bakeResults (joints, time = (min,max), sm = True, sb = 1)

… after importing maya.cmds as mc, of course. We change the tangent type of the baked keys as needed.
5/ parent the joint root to the world.
6/ remove all the matrix nodes in the rig.
7/ and then, remove the ‘rig’ node.

This is what I do before I export the animated skeleton as .FBX. For exporting the character, I do not bake the joints’ animation because there’s none, but before step 5 I remove ALL the inputs to the joints using this:

  for eachJoint in joints:
  	inputs = [eachInput for eachInput in pymel.core.ls(eachJoint)[0].inputs() if eachInput.type() != 'joint']
  	mc.delete (inputs)

… and then I delete the rig node. I believe this step is what could solve your issue.

I’m not saying this is the proper way to do it, but it seems it’s working for us so far. We have other issues on the Unity side that I’m figuring out, but it’s not related to mGear at all.

3 Likes

Hey all.
I have a similar setup here as above :point_up_2:
So I start with exporting the character which is mesh and joints only using the method above.
When i want to export out animations for this character, if im using references I will just run a simple script that will duplicate the skeleton joint at root and un-parent so it is now in world and in no hierarchy. It is important here that it matches your model export setup.
In order to get the animation out correct I keep connections on the duplicated skeleton so I can simply select the Dup joint heirachy and export as FBX and let the export bake the animation for me.
Then I can just delete the Dup setup and keep my animation scene clean.

import maya.cmds as mc 
mc.duplicate(rr = 1, ic = 1) 
mc.parent(world=True)

Double check your joint Duplicate root as this may have a _1 or 1 appended to it. So in this case I just rename
mc.rename("skel_root1", "skel_root")

Again the useful thing about duplicating reference objects is that it will strip off the namespace for you whilst keeping the connections.

Hope this helps :slight_smile:

1 Like