Search Unity

  1. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice
  2. Unity is excited to announce that we will be collaborating with TheXPlace for a summer game jam from June 13 - June 19. Learn more.
    Dismiss Notice

Question Combine Animation Clips with script

Discussion in 'Animation' started by andthenwhat, Jan 17, 2022.

  1. andthenwhat

    andthenwhat

    Joined:
    May 11, 2015
    Posts:
    19
    I'm trying to concatenate two AnimationClips in C# where I have clip1 and clip2 and want to create an AnimationClip clip3 that is just clip1 then clip2 back to back.

    I'm good with AssetDatabase.CreateAsset once I've got the AnimationClip, just don't know how to create the AnimationClip... any info greatly appreciated

    Does anyone know how to do this?
     
  2. Kybernetik

    Kybernetik

    Joined:
    Jan 3, 2013
    Posts:
    2,581
    AnimationUtility should have everything you need. Methods like Get/SetCurveBindings and Get/SetEditorCurve.
     
  3. andthenwhat

    andthenwhat

    Joined:
    May 11, 2015
    Posts:
    19
    Thank you for the reply!

    Sorry, my question was badly written:

    I know how to duplicate the first AnimationClip and copy/combine editor curves and events from all the other clips (and shift the event and key times out by the first clip's duration + 1/frameRate) in order to get all the curves lined up in the output clip, but what I don't know how to do is:

    How do I Adjust the key values (e.g. RootT and RootQ (are there others?)) to make sure the second clip carries the root motion from the first clip (otherwise, the second clip would just start from the origin)

    I'm ignoring object reference curves for now, but is there anything else I need to copy over?