Search Unity

  1. Get all the Unite Berlin 2018 news on the blog.
    Dismiss Notice
  2. Unity 2018.2 has arrived! Read about it here.
    Dismiss Notice
  3. Improve your Unity skills with a certified instructor in a private, interactive classroom. Learn more.
    Dismiss Notice
  4. ARCore is out of developer preview! Read about it here.
    Dismiss Notice
  5. Magic Leap’s Lumin SDK Technical Preview for Unity lets you get started creating content for Magic Leap One™. Find more information on our blog!
    Dismiss Notice
  6. Want to see the most recent patch releases? Take a peek at the patch release page.
    Dismiss Notice

Importing (slightly) more complex animations from Blender to Unity.

Discussion in 'External Tools' started by cjddmut, Feb 22, 2014.

  1. cjddmut

    cjddmut

    Joined:
    Nov 19, 2012
    Posts:
    84
    I have zero clue if the problem I'm having is due to Blender or if the problem I'm having is due to Unity but I'm hoping some savvy Blender/Unity user might be able to help me out ;).

    I think this will be easier to describe what it is that I am trying to do. For a project I have a simple humanoid model I created and rigged using Rigify in Blender (I've now realized that Rigify doesn't parent things the way Unity would like for humanoids but that's not really a problem here). In Unity, we intend for this model to carry a minigun. We purposely do not want the minigun model to actually be part of the humanoid model so a different model was created for the minigun. After creating the model, I then created a new armature for the minigun with a deform bone for the entire gun.

    I wanted to animate a run with the minigun in Blender so I did what seemed to make sense to me. I created a disconnected bone for the minigun on the handle and the trigger and then added a Copy Transform constraint on the humanoid's IK hand to be on the newly created bones. So that the minigun always stayed with the character, I added a Copy Location constraint (with offset) on the primary minigun bone to the torso of the humanoid.

    In blender, this appears to work pretty well. However, the animation is all out of whack in Unity. Below is frame one in each.

    $ss1.png

    What's also weird is if I have loop time unchecked then my minigun will quite rudely run away from the humanoid.

    $ss2.png

    If I do check loop time then the minigun will still move away (which is a recent thing that I swear I did not touch the minigun to cause) and we'll still see stretching of the arms and the hands are no longer on the gun's handles.

    $ss3.png

    I am really at a loss here and not sure what to do. Any help would be much appreciated. I should also note that I am seeing other odd behavior in Blender around the Copy * constraints that I made a post about on blenderartists.org but the post has not been approved yet. Since it's possible these issues are related, I will update this post with a link to that post once I can.

    Hep! (Please let me know what other information I can give to aid)
    C.J.
     
    Last edited: Feb 22, 2014
  2. Dantus

    Dantus

    Joined:
    Oct 21, 2009
    Posts:
    5,668
    How do you know this is not the cause for the issue?
     
  3. cjddmut

    cjddmut

    Joined:
    Nov 19, 2012
    Posts:
    84
    While Rigify has placed the bones in a way that Unity doesn't like for humanoids, I still import the animations as generic. If this was the cause of the issue then I would likely see this issue with other generic animations.

    I suspect the problem involves the Copy Location/Transform bone constraints that are set up in Blender. They aren't acted as expected once imported to Unity. I'm not sure if I'm just not using them right or if it's one of those things that doesn't translate well so I should avoid.
     
  4. Dantus

    Dantus

    Joined:
    Oct 21, 2009
    Posts:
    5,668
    You are right, there should be no issue with the generic animations in this configuration.

    The constraints in Blender were never the cause for issues I was having. Did you make sure that the all the involved objects in Blender have a scale of (1, 1, 1)? And did you make sure that both the model and the rig have the origin at (0, 0, 0)?

    Further as you keyframe an animation, did you try to make an animation that has a keyframe for all bones to check whether this solves the issue?
    The most reliable way to create animations in Blender for Unity was to use actions only. What are you using to create animations?
     
  5. jRocket

    jRocket

    Joined:
    Jul 12, 2012
    Posts:
    377
    Instead of constraining, just parent the minigun to your characters hand bone so it is part of the hierarchy.
     
  6. cjddmut

    cjddmut

    Joined:
    Nov 19, 2012
    Posts:
    84
    All scales are 1.0 and every origin is at (0, 0, 0). I have made sure to record each bone in at least the first and final keyframe to make sure they were accounted for.

    For creating animations, I use the action editor to create new actions and turn on the record on the timeline while I pose the rig for the specific keyframe. If there's another way to create animations, I'm unsure of it.

    This doesn't really work for me since I want both hands to hold on to the gun at two specific different points. I could parent to one hand but I would still need to use a Copy Transform/Location constraint on the other hand which would likely continue to cause issues with the hand.
     
    Last edited: Feb 24, 2014