Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.

Boned Animations

Discussion in 'Editor & General Support' started by arton, Jun 11, 2005.

  1. arton

    arton

    Joined:
    Jun 11, 2005
    Posts:
    38
    I'm currently trying to get a model with a bone system and animations from Cinema 4d into Unity. I exported the fbx, and got the mesh in. In the hierarchy I can see the bones nested within the mesh. In the project view, within the imported fbx I see a "C4D Animation Take". From there I'm not really sure where to go, I haven't been able to find much mention of the process used. Do I use a mesh deformer, or an Animation clip, or some tag in Cinema 4D? Any help would be great. By the way, this seems like a really well thought out tool, and I'm very impressed by what's possible so far. The art pipeline seems really great so far.
    Good Work!
    -Arton Ragsdale
     
  2. arton

    arton

    Joined:
    Jun 11, 2005
    Posts:
    38
    Okay, well I've made a little progress.

    I'm doing a bunch of experiments with the humanoid.fbx they include in examples, and my own files in Cinema 4d. I figured out that point selection tags don't export as vertex maps, while claude bonet does, but I think there's something wrong with how Cinema 4D is exporting fbx files. I'll provide more details after I narrow down where the problem is coming from. It's nice to see that they do provide direct control of bones through the editor.
    By the way, it's quite helpful to set the fbx exporter to export text if anyone else is messing with the same stuff out of C4D.
     
  3. arton

    arton

    Joined:
    Jun 11, 2005
    Posts:
    38
    Well, I've gotten some decent looking animations from C4D to Unity finally. Woohoo! It seems that the main problem was just with the point selections not exporting as vertex maps. I use that method a lot because the characters I've been making lately have very simple geometry.
    -Claude Bonet works very well though.

    The only question I really have now is about multiple animations.
    -Is it possible to rename the animations within Unity? The default name from C4D is "C4D Animation Take".
    -If not, does anyone know of a way to export multiple animations out of one C4D file? Right now I'm guessing I'll have to make a seperate C4D file for each animation, and then bring them together in Unity.

    Quick note about the example animation file.
    The example file is a little confusing at first, here are the reasons I thought so.
    -the Humanoid and Humanoid:MaxToFilmbox are removed from the wrapper unity gives them (pretty minor)
    -The Humanoid object is scaled to about 2.5, this offsets and scales the mesh from the bounds, which is pretty wierd at first.
    -The Humanoid:MaxToFilmbox object which contains the bones is scaled to 0.1, which is fine, as this seems to be the place to scale without offsetting anything.
    (out of C4D, the bones are a child of the mesh, so this isn't a problem)

    not a big deal, but could be tightened up a bit, minus the exported camera and light too, to make it more straight forward and focused.

    I'm just glad to be able to get C4D work directly into a game!
    Unity rules!
    :D
     
  4. NicholasFrancis

    NicholasFrancis

    Joined:
    Apr 8, 2005
    Posts:
    1,587
    I'm unable to answer questions about this... Joe's the man behind that part of the code, and he's still away (actualy so am I, but I have a laptop)...

    Just glad to hear you're making progress on this. When Joe gets back, I'm sure he'll help you out - then I'll read the results and make some HOWTOs...
     
  5. arton

    arton

    Joined:
    Jun 11, 2005
    Posts:
    38
    Well, I've figured out a pretty good way to rename animation takes from Cinema 4D.
    -The first step is to go into C4D's Edit->preferences->Import/Export->FBX Export, and check the box for "Export As Text File".
    -Assuming you used Claude Bonet to assign vertex weights to your model, you can export the model and it's animation to FBX and view you animation in Unity.
    -To change the name of th animation, open the FBX in TextEdit (or your favorite text editor) and search for "C4D" or "C4D Animation Take", which will take you to a block of text like this-
    //
    Takes: {
    Current: "C4D Animation Take"
    Take: "C4D Animation Take" {
    FileName: "C4D Animation Take.tak"
    //

    Which you change to-
    //
    Takes: {
    Current: "YourAnimation1"
    Take: "YourAnimation1" {
    FileName: "YourAnimation1.tak"
    //

    This seemed to work fine in Unity and showed up with the new name.
    I think it should be easy to hack together a multitake FBX from multiple exported FBXs by just copying all the take information into one and renaming/numbering them. I'll experiment some more to see what I can figure out. I don't see any reason why it shouldn't be scriptable as well;)
    Of course, you could just have multiple fbxs in Unity and drag the animations into one object, but it would be nice to have them in one if possible.

    -Side Note-
    I would like to see future example FBXs be exported as Text files if possible from the software you're using. Being able to compare working files with broken ones can be very helpful. I had to import the Humanoid into Cinema 4D and then re-export it, which screwed it up pretty bad, but was still useful for troubleshooting.
     
  6. arton

    arton

    Joined:
    Jun 11, 2005
    Posts:
    38
    so far I'm having the best luck importing multiple fbx files in, and adding the animations from them into a root fbx. Here's the steps I take.

    -Make a C4D file completely boned and ready to animate, but with no keyframes or animation. Export this to use as a container for your animations.

    (If you use an fbx with an animation already included it doesn't get the root position of the bones right, and will screw up your animations. Actually, I think it will always be preferable to have a root container fbx to add animations to, as this was the only way I was able to get clean animations working.)

    -Save the C4D file with another name, or duplicate it. Use the new file for one animation. Repeat for as many animations as you need. Export these as fbx files.

    -With all your fbxs in Unity, add the root fbx with no animation into the scene, then cmd-select all the animations you want to add, and drag them into it in the Hierarchy.

    -select the container in the hierarchy (make sure the inspector is set to Full or Expert) and look under the Animation tab.
    Animations should have Size set to however many animations you dropped in, and there should be an Element object for each one. I believe the Elements can be used to blend animations, but I'll probably have to wait for more documentation to do that properly.

    Good luck!
     
  7. arton

    arton

    Joined:
    Jun 11, 2005
    Posts:
    38
    Oh Yeah! I forget to mention:

    -to test your new animations, just duplicate the "Play Animation" script included with the Character Animation example and modify it to match your animation names and whatever buttons you want. Thanks for that!