Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Questions about Keyframe Character Animation

Discussion in 'Animation' started by DreamGirlGames, Aug 30, 2014.

  1. DreamGirlGames

    DreamGirlGames

    Joined:
    Jul 3, 2014
    Posts:
    11
    I'm using Keyframe animation in Unity by having single short clips that I make in blender and then blend between by directly altering animation[].weight.

    After working with it for a bit, I'm starting to notice some inconsistencies between Blender and Unity.

    For example. I have a character's fist at position (0, 0, 0) on the first keyframe. On the next keyframe it's at (1, 1, 0). But when i blend between them (animation[].weight of both keyframes are equal) I don't get (0.5, 0.5, 0) I get things like (0.7, 0.1, 0). I thought it was some rigging thing (though I must admit I'm very new to 3D graphics--only a few months experience) but I did a full animation in blender, using the same keyframes and exporting it to Unity and I get similar, though not identical, inconsistencies.

    Has anyone else experienced this?

    Any help would be great!


    Hey there!
    I'm developing a competitive fighting game in Unity. I have an implementation for animation in mind, that I'm 99.9% sure is possible, but I am hitting some obstacles.

    The game runs at a fixed 60fps for both logic and rendering concurrently.
    Characters in the game have one discrete state in which they can be. These states are called Skills.
    Each Skill is made up of a certain number of Skill Frames. Each Skill frame has hitbox data, attack events, sfx events, movement events, etc. Every Update the characters' current Skill Frame is incremented by one until they reach the end and revert to their default 'Neutral' Skill. They can also 'cancel' into another Skill via specific inputs or enter into Hitstun, Blockstun or BeingThrown Skills when struck by an enemy attack.

    For actually rendering the characters I want to use 3D character models and keyframes(animation clips atm in Unity) on specific Skill Frames. I'm making the models and keyframes/animations in Blender and exporting them together as FBX files. There will be multiple specific characters as well as customizable characters that all share a rig so they can use all those Keyframes however they like.

    More specifically, though the amount doesn't really matter, to illustrate, each Skill will generally have 3 or so Keyframes--Startup, Impact, Follow-through.

    As an example: the 'Standing Jab' Skill would have 12 Skill Frames (0~11).
    Frame 4: Startup Keyframe
    Frame 6: Impact Keyframe
    Frame 9: Follow-through Keyframe

    Notice that the startup Keyframe is on Frame 4 and not Frame 0. This is because I want to be able to tween between an arbitrary 'Current Motion Data' and the next keyframe as a Skill begins. This is often a keyframe or tween from the character's 'Neutral' Skill but will just as often be from a tween or keyframe from another Skill. Similarly, notice that the last Skill Frame of Standing Jab has no Keyframe. The tweening here will target the first Keyframe on the next predicted skill. By default this prediction is the 'Idle' Skill. But if the character cancels into another skill for any reason, the target Keyframe will change. Again--here I will need some sort of 'Current Motion Data' (as it could be a tween or keyframe on the current frame) to tween from.

    I'm also hoping to use the Animator Component / Mecanim as it has nice built-in retargeting. It doesn't seem possible to create Animator States procedurally so currently I'm messing with AnimatorOverrideController to assign Clips every Update.

    Now to some actual questions...

    1) Is it possible to have a dynamic 'Animation Clip' object that I could change based on the tweening described above and just pass that to the AnimatorOverrideController?

    2) When an Animation Component or Animator Component deforms a Mesh, what does the data look like? The Method? Especially during Blending/Tweening. Can I access that--'Current Motion Data'? What exactly is passed to the Mesh to deform it or what does the Mesh look for to deform? Is it the Animation Curves Class? (this is only important if I can't send a dynamic Clip to the AnimatorOverrideController)

    3) I also need a decent way to save and organize so many (40+Skills * X characters * 1~5 keyframes) key frames (Animation Clips) as static variables so that I can access them easily.

    Any help or thoughts would be greatly appreciated.
    Thanks!
     
    Last edited: Sep 7, 2014
  2. TMPxyz

    TMPxyz

    Joined:
    Jul 20, 2012
    Posts:
    766
    Maybe I didn't understand your description completely, but why don't you just use the mecanim's built-in blending mechanism? I think it will handle the blending between different motions smoothly.
     
  3. DreamGirlGames

    DreamGirlGames

    Joined:
    Jul 3, 2014
    Posts:
    11
    Thanks for the response. It's a good question. As a fallback, I think I can just have a base Animator with two states that I just change the clips with the Overrider and blend between them. However, I'm under the impression that Mecanim blends based on two clips and an offset rather than incrementally. This means that I can only blend between keyframes and not from any tweens that have been generated.

    I forgot to mention that when tweaking Skills, if it's assigned to the skill frame, then the animation and mechanics all get altered together. In the case of using the Animator, I have to go in and change it to match any Skill changes. This is extra annoying because the timing in Animator isn't in frames.
     
    Last edited: Aug 31, 2014
  4. DreamGirlGames

    DreamGirlGames

    Joined:
    Jul 3, 2014
    Posts:
    11
    I found the exact solution I wanted, but I'm using Legacy.
    I have Clips that are simply keyframes (no real 'animation') that are 1.0 in length.
    I was using animation.crossfade at first, but now I use my own system for curves and things and assign animation[].weight directly.
    It's working great!
    BUT! I recently have been encountering some problems. I'm updating the original post to address it.