Search Unity

Failed approach for a complex set of mechanical animations?

Discussion in 'Animation' started by argbaygb, Sep 5, 2014.

  1. argbaygb

    argbaygb

    Joined:
    Dec 11, 2013
    Posts:
    4
    Hello!

    I'm trying to do a game similar to Star Wars: Episode 1 Racer. The podracer is modelled in Blender 3D and is composed of multiple separate objects (cockpit, engine nacelles, brakes). The visual and logic/physics components are completely separated.

    So far I've had decent success connecting the physics to the visual part by a custom controller that would rotate and move around each visual component to reflect the logic/physics simulation (e.g. nacelle thrust is oriented by n degrees to the left -> rotate the corresponding mesh object n degrees to the left).

    I'm now trying to rewrite this system using animations in order to simplify the script and get more control over the podracer movements. I've attached bones in the model and made a set of animations (through the Action Editor) in Blender. The problem that I'm facing is that I cannot have multiple animations played simultaneously on my model.

    So far I found out that:

    - when you export from blend to fbx files, keyframes are added for ALL bones on each animation. which is bad. I want to have an animation that only turns the engine nacelles bones, leaving the other bones untouched (so I can animate the nacelle and brakes bones separately)

    - the unity animation systems (both mecanim and the legacy one) are oriented towards smooth character animations, but it should be possible to combine the animations in the manner I need by using different animation layers in the legacy system

    - if I remove the keyframes added for the other bones at export time in the Unity animation window, I can easily play and stop animations ( animation.Play("brakesUp", AnimationPlayMode.Mix); ), but this would be an extremely long process for the entire model and so far I only managed to play a single animation at a time

    So, what do you think it would be best for me to do under these circumstances to get my model to support multiple independent animations that can be easily scriptable? By easily scriptable I ideally mean something like animation["turnLeftRight"].time = getAnimTimeFromLogicalLeftRightAngle(); )

    Attached a nacelle turn animation frame and gameobject structure for reference:

    pod.PNG structure.PNG
     
  2. argbaygb

    argbaygb

    Joined:
    Dec 11, 2013
    Posts:
    4
    Update: The only thing that seems to be failed is the blender -> fbx -> unity export.

    Previous to 2.71, Blender had a single fbx export variant (6.1 ASCII). This worked properly with unity animations, but forced keyframes for unaffected bones in each animation.

    Now Blender has a new export script for fbx 7.4 Binary. This new exporter does not force keyframes for bones that don't have any, but:

    - it changes the exported bone names ( "ArmatureName | BoneName" instead of simply "BoneName")
    - it looses connection between armatures and objects

    The first one does not seem to be a problem when exporting to Unity, but the latter is a major problem: all the animations get correctly exported to Unity (all keyframes have correct loc/rot/scales, no bogus keyframes added), but only affect the bone gameobjects, not the mesh ones. Any idea how to solve this? Note that I'm not using any armature modifiers in blender, only object-bone parenting.
     
  3. argbaygb

    argbaygb

    Joined:
    Dec 11, 2013
    Posts:
    4
    Update:

    As one would expect, the new exporter problem can be solved by manually parenting the mesh game objects to the bones after the model is exported to unity. This propagates the animations to the visual parts correctly, but it also means that this is a step I'd have to do after every re-export, which is, again, extremely painful to do.

    attached modified Unity object structure:

    modified.PNG
     
  4. GoesTo11

    GoesTo11

    Joined:
    Jul 22, 2014
    Posts:
    604
    What about creating an Avatar mask? Mask out the areas that you have keyframes that you don't want. I'm a noob so don't be surprised if I have no idea what I'm talking about. Just an idea.
     
  5. argbaygb

    argbaygb

    Joined:
    Dec 11, 2013
    Posts:
    4
    Hi! Thanks for your reply, but that's not a problem anymore. With the legacy system I can easily separate the animations into layers now. The problem is that the objects now lose connection to the bone animations when exported into unity from blender and they have to be nested manually in order to make them animate, as shown in my previous post.