Search Unity

Copying -one- Keyframe data from one animation to another

Discussion in 'Animation' started by Jesse_Pixelsmith, Mar 23, 2015.

  1. Jesse_Pixelsmith

    Jesse_Pixelsmith

    Joined:
    Nov 22, 2009
    Posts:
    296
    So for our game (3d cube/voxel) I'm doing animation from directly inside of Unity for characters. They have simple rigs, so I'd rather not get blender involved etc.

    For the most part it works well - however I'm running into an issue when I want to revise things.

    I find myself unable to copy a single set of keyframe data from one animation to another. I'm able to copy that single keyframe across the animation, but when I try to paste it into another animation, it seems to want to overwrite every frame of that animation.

    What I'm trying to do is when I change the say , AttackReady stance, also change the first frame of AttackA to match that. Right now it seems the only way to do it is manually do the changes on each to match. I just want to copy and paste!

    Is there a way to get this done easier that I'm missing?

    Thanks :)
     
  2. medhue

    medhue

    Joined:
    Aug 24, 2014
    Posts:
    176
    Yes, that is kind of strange, but why can't you just delete the frames you don't need? You said it's a simple rig, and I'm assuming the AttackReady is only a few keyframes, maybe 4-5. So, if you wanted to just use the first keyframe, you'd just select the very top keyframe of the frames you don't want and rightclick/delete. If it gets messy, and screws with the current keyframe in the AttackA, then just paste all those keyframes after the actual attackA animation, and delete all the keyframe you don't want, and then move the keyframe you do want, to the first frame of the animation. I hope that makes sense.
     
  3. medhue

    medhue

    Joined:
    Aug 24, 2014
    Posts:
    176
    I feel like this is confusing when it should be simple. So, I will explain again, in a different way. First you goto your ready animation, click record, select a keyframe, and hit ctrl+c. You then goto your AttackA animation, and past the Attackready keyframes after the AttackA keyframes. So, if the AttackA is 1 second, you past the AttackReady keyframes at 2 seconds, delete what you don't need, and then move the keyframe you want from the AttackReady, to the first frame.
     
  4. Jesse_Pixelsmith

    Jesse_Pixelsmith

    Joined:
    Nov 22, 2009
    Posts:
    296
    That's what I was hoping I would do, but the stuff I paste literally overwrites everything at each timestamp on the next animation. I tried to "move it out of the way" Like, say my attack animation is only 0 - 60 frames. I move to frame 360 and paste. Should be plenty of room, but it still deletes all my stuff on 0-60 and replaces it with the stuff I pasted.

    Here is my AttackA


    Here is my ReadyStance:


    Here is what happens to my AttackA when I paste the above selected keyframe into my AttackA anim. (This is the same animation as the first pic.


    As you can see, all of my keyframes were overwritten, even the 2 on frames 6 and 12 when nothing should have even pasted over those.

    Literally at a loss, and I'd be surprised if there was something I could do on my end with the anim tools to fix this. I will probably file it as a bug unless its somehow working as intended. (if so then that's a pretty bad intention :)


    In the meantime I might check this out that I saw in unity answers.

    "Try the Copy transform script! I used it for replacing objects. But now it worked well for the animation.http://wiki.unity3d.com/index.php?title=CopyTransform"


    I guess keyframes are just transform position/rotation data, and selecting all the frames selects all the transforms.

    But if anyone has better ideas would love to hear it.
     
  5. Jesse_Pixelsmith

    Jesse_Pixelsmith

    Joined:
    Nov 22, 2009
    Posts:
    296
    Yeah unfortunately that script doesn't work so well. Has a hard time with multiple transforms, and when pasting it doesnt dirty the animation keys.
     
  6. theANMATOR2b

    theANMATOR2b

    Joined:
    Jul 12, 2014
    Posts:
    7,790
    @JesseAlexander
    Did you attempt to paste after the existing keyframes as medhue suggested?
    So moving the timeslider past the existing keyframes on AttackA and paste the new keyframes.
    I have not performed this action so unsure if that's a solution.
    I remember reading about difficulty with this in 4x.

    Please update if you find a solution.
     
  7. Jesse_Pixelsmith

    Jesse_Pixelsmith

    Joined:
    Nov 22, 2009
    Posts:
    296
    Yes I did, that was what my post 2 above was mentioning. It failed horribly and overwrote my whole animation
     
  8. v2-Ton-Studios

    v2-Ton-Studios

    Joined:
    Jul 18, 2012
    Posts:
    238
    I know I'm late to the party, but I think it deserves a bump. My current workflow suffers fantastically from not being able to do this. I'm truly in copy paste hell going back and forth between specific items in one animation to get them to sync correctly with another. This is especially bad if I make a change in one animation and then have to update all the transition animations.

    To give you guys an idea of how painful this can be here's an example workflow -- almost identical to what I have today...

    Consider a jump animation, with appropriate transitions:

    JumpFromGround
    JumpRising
    JumpFalling
    JumpLand

    Now consider transitions for things like different movement types and running into a wall or getting hit while in the air:

    JumpFromRun
    JumpFromRunRising
    JumpFromRunFalling
    JumpFromRunLand
    JumpToWallHit
    JumpRunToWallHit
    JumpDamage
    JumpRunDamage

    If I was trying to do something on the order of a modern Flashback I'd have even more transitions:

    JumpToGrabDirectlyAbove
    JumpToReachAndGrab
    (plus all the transitions needed for the run variants.)

    Now imagine I update the JumpFalling animation, I have to edit all the things that "touch" it: JumpRising, JumpLand, JumpToWallHit, JumpDamage, JumpToGrabDirectlyAbove, JumpToReachAndGrab.

    Clearly it gets hard to keep in sync very quickly.

    Perhaps this is more acute when trying to build rich 2D "rigged" animations, but it seems like a general issue. (By "rigged" I mean in the way that Mika Mobile made popular with Battleheart, but imagine doing that entirely in Unity -- Mika did it with Maya I believe -- and aiming to tackle something like Another World or Flashback.)

    The need is simple...

    Allow the end frames of animation A to be the same as start frames of animation B. For instance, allow the start frame of my Run animation to be the same as my IdleToRun transition animation.

    Some solution options...

    Simple / hacky solution: allow keyframes at any point in animation A to be copy / pasted into animation B AND only update the affected keyframes of animation B, at the timeline point for which is pasted them. See above: currently the entire animation is blown away.

    More ideal solution: Allow animations to be viewed as an orchestrated chain, rather than discreet operations. Automatically allow me to make the End and Start of two distinct animations the same, so if I edit one the other gets automatically updated. Further, allow the "end / start" to be shared across multiple animations, creating if you will a master-instance model of certain aspects of the animation "chain". My understanding is that programs like Max allow this by way of animating things along a single timeline and then saving out "time slices" for specific animations.

    NOTE: The current model of a transition time / blending does not work. I have all my transitions to 0 seconds because they cause far too many issues. Why? Often in these 2D "rigged" set ups you have to turn on and off pieces of the model e.g. a shield that is in block pose versus idle pose (transitioning between that causes both items to be visible at the same time... looks terrible). Also, simply switching the sprite is often not enough as sometimes the sprite needs to be reordered (not animatable) or flipped, which causes other problems such as flipped elements (scale.x = -1) not being able to be rotated properly past a certain point.

    I hope this helps. Creating a better system here would save me many hours each week.
     
    Last edited: Jun 27, 2015
    theANMATOR2b likes this.
  9. robcbryant

    robcbryant

    Joined:
    Mar 15, 2014
    Posts:
    3
    I've been dealing with this same issue. It's incredibly frustrating. I also tried moving both the original animation to well past the length of the pasted animation, and pasting the copied keyframe well after the animation I'm attempting to update--both completely overwrite the animation. I'll keep looking for solutions.
     
  10. robcbryant

    robcbryant

    Joined:
    Mar 15, 2014
    Posts:
    3
    I just figured something out--but it only works in my particular situation. I'm doing sprite based animation on a boss and rotate the controller whether or not it's facing right or left. This requires me to update the z values (layers) on the left and right facing boss' sub sprites (arms, legs, feet, etc.) for each animation. Left and Right both need separate animations that are duplicates, save for the z layer values that need to be changed.

    Anyway--I only need to update the z values once because they don't update throughout any of the animations so by ONLY selecting the z values of each object in the keyframe rather than the entire keyframe still overwrites all other z values for the selected objects when I paste it into a new animation--but I don't need any z values in the other animations aside from the initial state so it's actually doing half the work for me.

    This solution obviously only works for static animation keys that don't need to change once initialized--and it's barely a solution.
     
  11. v2-Ton-Studios

    v2-Ton-Studios

    Joined:
    Jul 18, 2012
    Posts:
    238
    I tweeted this, but thot I'd share here as well... you can now copy-paste keyframes between animations w the 5.1.2P3 patch: https://unity3d.com/unity/qa/patch-releases/5.1.2p3!

    Other bugs are created by the patch (like an annoying issues around saving when in animation mode -- be sure to exit animation mode, then save), but otherwise it solves the animation editor's performance issue and allows copy pasting of keyframes. These fixes are insanely good for productivity, spread the word!
     
    theANMATOR2b likes this.